More Python2 migrations, patch from KA.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18837 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2003-01-20 23:41:15 +00:00
parent 2fa5f840d5
commit f86c833fe0
15 changed files with 51 additions and 58 deletions

View File

@@ -191,7 +191,7 @@ class wxPyNonWindowingErrorHandler:
self.file = file
def write(self,s):
import sys
if string.find(s,"Warning") <> 0\
if s.find("Warning") <> 0\
and self.this_exception is not sys.last_traceback:
wxPyNonWindowingError("The Python interpreter encountered an error "
"not handled by any\nexception handler--this "
@@ -380,7 +380,7 @@ class wxPyNonFatalErrorDialogWithTraceback(wxDialog):
value = value[:-1]
if _debug:
print "%s.SetTraceback(): ...SetValue('%s' (^M=\\r; ^J=\\n))"\
% (self,string.replace(value,'\n',"^J"))
% (self,value.replace('\n',"^J"))
c.SetValue(value)
# Despite using the wxADJUST_MINSIZE flag in the
@@ -399,7 +399,7 @@ class wxPyNonFatalErrorDialogWithTraceback(wxDialog):
print "%s.SetTraceback(): %s.GetBestSize() = (%s,%s)"\
% (self,c,size.width,size.height)
w,h = 0,0
for v in string.split(value,"\n"):
for v in value.split("\n"):
pw,ph,d,e = t = c.GetFullTextExtent(v)
if _debug:
print v, t
@@ -669,7 +669,7 @@ def _startmailerwithhtml(mailto,subject,html,text=None,mailfrom=None):
s = 'mailto:%s?subject=%s&body=%s' % (mailto,
urllib.quote(subject),
urllib.quote(
string.replace(text,'\n','\r\n'),
text.replace('\n','\r\n'),
""))
# Note that RFC 2368 requires that line breaks in the body of
@@ -797,7 +797,7 @@ def wxPyResizeHTMLWindowToDispelScrollbar(window,
# Will go no further than specified fraction of display size.
w = 200
if type(fraction) == type(''):
fraction = string.atoi(fraction[:-1]) / 100.
fraction = int(fraction[:-1]) / 100.
ds = wxDisplaySize ()
c = window.GetInternalRepresentation ()
while w < ds[0] * fraction:
@@ -812,7 +812,7 @@ def wxPyResizeHTMLWindowToDispelScrollbar(window,
w = w + 20
else:
if type(defaultfraction) == type(''):
defaultfraction = string.atoi(defaultfraction[:-1]) / 100.
defaultfraction = int(defaultfraction[:-1]) / 100.
defaultsize = (defaultfraction * ds[0], defaultfraction * ds[1])
if _debug:
print 'defaultsize =',defaultsize

View File

@@ -13,7 +13,6 @@
from wxPython.wx import *
from CDate import *
import string, time
CalDays = [6, 0, 1, 2, 3, 4, 5]

View File

@@ -24,7 +24,6 @@
import os, time
from wxPython.wx import *
from string import *
import selection
import images
@@ -650,7 +649,7 @@ class wxEditor(wxScrolledWindow):
def CopyToClipboard(self, linesOfText):
do = wxTextDataObject()
do.SetText(string.join(linesOfText, os.linesep))
do.SetText(os.linesep.join(linesOfText))
wxTheClipboard.Open()
wxTheClipboard.SetData(do)
wxTheClipboard.Close()

View File

@@ -17,7 +17,7 @@
#---------------------------------------------------------------------------
import os, sys, string
import os, sys
from wxPython.wx import *
dir_path = os.getcwd()
@@ -29,7 +29,7 @@ def ConvertBMP(file_nm):
fl_fld = os.path.splitext(file_nm)
ext = fl_fld[1]
ext = string.lower(ext[1:])
ext = ext[1:].lower()
if ext == 'bmp':
image = wxImage(file_nm, wxBITMAP_TYPE_BMP)
elif ext == 'gif':
@@ -278,14 +278,14 @@ class FindFiles:
dirlist = [".."]
self.dir = dir
self.file = ""
mask = string.upper(mask)
mask = mask.upper()
pattern = self.MakeRegex(mask)
for i in os.listdir(dir):
if i == "." or i == "..":
continue
path = os.path.join(dir, i)
path = string.upper(path)
value = string.upper(i)
path = path.upper()
value = i.upper()
if pattern.match(value) != None:
filelist.append(i)

View File

@@ -121,7 +121,7 @@ see the appropriate "stub" file in the wxPython demo.
"""
from wxPython.wx import *
import string, sys, types, tempfile, os
import sys, tempfile, os
class _MyStatusBar(wxStatusBar):
def __init__(self, parent,callbacks=None,useopenbutton=0):

View File

@@ -1,7 +1,7 @@
from wxPython.wx import wxLayoutConstraints,\
wxTop, wxLeft, wxBottom, wxRight, \
wxHeight, wxWidth, wxCentreX, wxCentreY
import re,string
import re
class Layoutf(wxLayoutConstraints):
"""
@@ -130,8 +130,8 @@ time of this writing not documented.
self.pack(pstr,winlist)
def pack(self, pstr, winlist):
pstr = string.lower(pstr)
for item in string.split(pstr,';'):
pstr = pstr.lower()
for item in pstr.split(';'):
m = self.rexp1.match(item)
if m:
g = list(m.groups())
@@ -159,8 +159,8 @@ time of this writing not documented.
else: func(winlist[g[4]], cmp)
def debug_pack(self, pstr, winlist):
pstr = string.lower(pstr)
for item in string.split(pstr,';'):
pstr = pstr.lower()
for item in pstr.split(';'):
m = self.rexp1.match(item)
if m:
g = list(m.groups())

View File

@@ -405,8 +405,7 @@ class FSTreeModel(BasicTreeModel):
"""
def __init__(self, path):
BasicTreeModel.__init__(self)
import string
fw = FileWrapper(path, string.split(path, os.sep)[-1])
fw = FileWrapper(path, path.split(os.sep)[-1])
self._Build(path, fw)
self.SetRoot(fw)
self._editable = true
@@ -431,8 +430,7 @@ class LateFSTreeModel(FSTreeModel):
"""
def __init__(self, path):
BasicTreeModel.__init__(self)
import string
name = string.split(path, os.sep)[-1]
name = path.split(os.sep)[-1]
pathpart = path[:-len(name)]
fw = FileWrapper(pathpart, name)
self._Build(path, fw)

View File

@@ -15,7 +15,7 @@
# add index to data list after parsing total pages for paging
#----------------------------------------------------------------------------
import os, sys, string, copy
import os, sys, copy
from wxPython.wx import *
import copy
@@ -46,7 +46,7 @@ class PrintBase:
return wxColour(fcolour[0], fcolour[1], fcolour[2])
def OutTextRegion(self, textout, txtdraw = TRUE):
textlines = string.splitfields(textout, '\n')
textlines = textout.split('\n')
y = copy.copy(self.y) + self.pt_space_before
for text in textlines:
remain = 'X'
@@ -88,7 +88,7 @@ class PrintBase:
def SetFlow(self, ln_text, width):
width = width - self.pcell_right_margin
text = ""
split = string.split(ln_text)
split = ln_text.split()
if len(split) == 1:
return ln_text, ""
@@ -109,12 +109,12 @@ class PrintBase:
text = text + bword
cnt = cnt + 1
else:
remain = string.joinfields(split[cnt:],' ')
text = string.strip(text)
remain = ' '.join(split[cnt:])
text = text.strip()
return text, remain
remain = string.joinfields(split[cnt:],' ')
vout = string.strip(text)
remain = ' '.join(split[cnt:])
vout = text.strip()
return vout, remain
def SetChar(self, ln_text, width): # truncate string to fit into width
@@ -129,7 +129,7 @@ class PrintBase:
return text
def OutTextPageWidth(self, textout, y_out, align, indent, txtdraw = TRUE):
textlines = string.splitfields(textout, '\n')
textlines = textout.split('\n')
y = copy.copy(y_out)
pagew = self.parent.page_width * self.pwidth # full page width
@@ -169,7 +169,7 @@ class PrintBase:
def GetNow(self):
full = str(wxDateTime_Now()) # get the current date and time in print format
flds = string.splitfields(full)
flds = full.split()
date = flds[0]
time = flds[1]
return date, time

View File

@@ -30,7 +30,7 @@ etc... But it's a good start.
from wxPython.wx import *
from wxPython.stc import *
import sys, string, keyword
import sys, keyword
from code import InteractiveInterpreter
#----------------------------------------------------------------------
@@ -238,7 +238,7 @@ class PyShellWindow(wxStyledTextCtrl, InteractiveInterpreter):
lastPos = self.GetTextLength()
if self.lastPromptPos and self.lastPromptPos != lastPos:
self.SetLexer(wxSTC_LEX_PYTHON)
self.SetKeywords(0, string.join(keyword.kwlist))
self.SetKeywords(0, ' '.join(keyword.kwlist))
self.Colourise(self.lastPromptPos, lastPos)

View File

@@ -72,7 +72,6 @@ from wxPython.wx import *
import xmlrpcserver,xmlrpclib
import threading
import SocketServer
import string
import new
import sys
@@ -305,7 +304,7 @@ class rpcMixin:
event.rpcStatusLock.acquire()
doQuit = 0
try:
methsplit = string.split(event.method,'.')
methsplit = event.method.split('.')
meth = self
for piece in methsplit:
meth = getattr(meth,piece)

View File

@@ -5,7 +5,7 @@
from wxPython.wx import *
from wxPython.grid import *
from string import *
import string
#---------------------------------------------------------------------------
class CTextCellEditor(wxTextCtrl):
@@ -124,7 +124,7 @@ class CCellEditor(wxPyGridCellEditor):
elif key < 256 and key >= 0 and chr(key) in string.printable:
ch = chr(key)
if not evt.ShiftDown():
ch = string.lower(ch)
ch = ch.lower()
if ch is not None: # If are at this point with a key,
self._tc.SetValue(ch) # replace the contents of the text control.
@@ -265,10 +265,10 @@ class CSheet(wxGrid):
crlf = chr(13) + chr(10) # CrLf characters
tab = chr(9) # Tab character
rows = split(s, crlf) # split into rows
rows = s.split(crlf) # split into rows
rows = rows[0:-1] # leave out last element, which is always empty
for i in range(0, len(rows)): # split rows into elements
rows[i] = split(rows[i], tab)
rows[i] = rows[i].split(tab)
# Get the starting and ending cell range to paste into
if self._selected == None: # If no cells selected...

View File

@@ -29,7 +29,7 @@ History:
__version__ ="$Revision$"
# $RCSfile$
import sys, string, code, traceback
import sys, code, traceback
from wxPython.wx import *
from wxPython.html import *
@@ -90,7 +90,7 @@ class PyShellInput(wxPanel):
return
text =self.entry.GetValue()
# weird CRLF thingy
text =string.replace(text, "\r\n", "\n")
text = text.replace("\r\n", "\n")
# see if we've finished
if (not (self.first_line or text[-1] =="\n") # in continuation mode
or (text[-1] =="\\") # escaped newline
@@ -193,9 +193,9 @@ class PyShellOutput(wxPanel):
if 0 and __debug__: sys.__stdout__.write(text)
# handle entities
for (symbol, eref) in self.erefs:
text =string.replace(text, symbol, eref)
text = text.replace(symbol, eref)
# replace newlines
text =string.replace(text, "\n", style[2])
text = text.replace("\n", style[2])
# add to contents
self.text =self.text +style[0] +text +style[1]
if not self.in_batch: self.UpdWindow()
@@ -302,14 +302,14 @@ class PyShell(wxPanel):
(etype, value, tb) =sys.exc_info()
# remove myself from traceback
tblist =traceback.extract_tb(tb)[1:]
msg =string.join(traceback.format_exception_only(etype, value)
msg = ' '.join(traceback.format_exception_only(etype, value)
+traceback.format_list(tblist))
self.output.write_exc(msg)
def ShowSyntaxError(self):
"""display message about syntax error (no traceback here)"""
(etype, value, tb) =sys.exc_info()
msg =string.join(traceback.format_exception_only(etype, value))
msg = ' '.join(traceback.format_exception_only(etype, value))
self.output.write_exc(msg)
def OnSize(self, event):

View File

@@ -738,7 +738,7 @@ class wxTimeCtrl(wxTextCtrl):
# Process AM/PM cell
elif pos == dict_start['am_pm']:
char = string.upper(char)
char = char.upper()
if char not in ('A','P'): return # disallow all but A or P as 1st char of column
newtext = text[:pos] + char + text[pos+1:]
else: return # not a valid position

View File

@@ -20,7 +20,6 @@ Original comment follows below:
"""
from wxPython import wx
import string
# Not everybody will have Numeric, so let's be cool about it...
try:

View File

@@ -89,7 +89,6 @@ from wxPython.wx import *
from wxPython.html import *
import wxPython.wx
import string
import types
#----------------------------------------------------------------------
@@ -146,12 +145,12 @@ class wxpTagHandler(wxHtmlWinTagHandler):
if tag.HasParam('WIDTH'):
width = tag.GetParam('WIDTH')
if width[-1] == '%':
self.ctx.floatWidth = string.atoi(width[:-1], 0)
self.ctx.floatWidth = int(width[:-1], 0)
width = self.ctx.floatWidth
else:
width = string.atoi(width)
width = int(width)
if tag.HasParam('HEIGHT'):
height = string.atoi(tag.GetParam('HEIGHT'))
height = int(tag.GetParam('HEIGHT'))
self.ctx.kwargs['size'] = wxSize(width, height)
# parse up to the closing tag, and gather any nested Param tags.
@@ -185,7 +184,7 @@ class wxpTagHandler(wxHtmlWinTagHandler):
if name == 'id':
theID = -1
try:
theID = string.atoi(value)
theID = int(value)
except ValueError:
theID = getattr(self.ctx.classMod, value)
value = theID
@@ -202,9 +201,9 @@ class wxpTagHandler(wxHtmlWinTagHandler):
# convert to wxColour
elif value[0] == '#':
try:
red = string.atoi('0x'+value[1:3], 16)
green = string.atoi('0x'+value[3:5], 16)
blue = string.atoi('0x'+value[5:], 16)
red = int('0x'+value[1:3], 16)
green = int('0x'+value[3:5], 16)
blue = int('0x'+value[5:], 16)
value = wxColor(red, green, blue)
except:
pass
@@ -229,7 +228,7 @@ class _Context:
# Function to assist with importing packages
def _my_import(name):
mod = __import__(name)
components = string.split(name, '.')
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod