Run 2to3 over the Demo/ directory to shut up parse errors from 2to3 about lingering print statements.

This commit is contained in:
Collin Winter 2007-07-17 20:59:35 +00:00
parent a8c360ee76
commit 6f2df4d5e1
132 changed files with 1070 additions and 1080 deletions

View file

@ -112,7 +112,7 @@ class Dialog:
def addchoices(self):
self.choices = {}
list = []
for k, dc in self.options.items():
for k, dc in list(self.options.items()):
list.append((k, dc))
list.sort()
for k, (d, c) in list:
@ -157,7 +157,7 @@ class PackDialog(Dialog):
try:
self.dialog.widget.pack(**{self.option: self.current})
except TclError as msg:
print msg
print(msg)
self.refresh()
class booleanoption(packoption, BooleanOption): pass
@ -213,7 +213,7 @@ class RemotePackDialog(PackDialog):
'info',
self.widget))
except TclError as msg:
print msg
print(msg)
return
dict = {}
for i in range(0, len(words), 2):
@ -240,7 +240,7 @@ class RemotePackDialog(PackDialog):
self.dialog.master.tk.merge(
self.current))
except TclError as msg:
print msg
print(msg)
self.refresh()
class booleanoption(remotepackoption, BooleanOption): pass
@ -256,11 +256,11 @@ class WidgetDialog(Dialog):
Dialog.__init__(self, widget)
def fixclasses(self):
if self.addclasses.has_key(self.klass):
if self.klass in self.addclasses:
classes = {}
for c in (self.classes,
self.addclasses[self.klass]):
for k in c.keys():
for k in list(c.keys()):
classes[k] = c[k]
self.classes = classes
@ -273,7 +273,7 @@ class WidgetDialog(Dialog):
def update(self):
self.current = {}
self.options = {}
for k, v in self.configuration.items():
for k, v in list(self.configuration.items()):
if len(v) > 4:
self.current[k] = v[4]
self.options[k] = v[3], v[2] # default, klass
@ -286,7 +286,7 @@ class WidgetDialog(Dialog):
try:
self.dialog.widget[self.option] = self.current
except TclError as msg:
print msg
print(msg)
self.refresh()
class booleanoption(widgetoption, BooleanOption): pass
@ -375,7 +375,7 @@ class RemoteWidgetDialog(WidgetDialog):
self.widget,
'config'))
except TclError as msg:
print msg
print(msg)
return
dict = {}
for item in items:
@ -399,7 +399,7 @@ class RemoteWidgetDialog(WidgetDialog):
'-'+self.option,
self.current)
except TclError as msg:
print msg
print(msg)
self.refresh()
class booleanoption(remotewidgetoption, BooleanOption): pass
@ -446,6 +446,6 @@ def opendialogs(e):
try:
RemotePackDialog(list, list.app, widget)
except TclError as msg:
print msg
print(msg)
test()

View file

@ -75,7 +75,7 @@ class EditableManPage(ScrolledText):
# Initialize parsing from a particular file -- must not be busy
def _startparser(self, fp):
if self.busy():
raise RuntimeError, 'startparser: still busy'
raise RuntimeError('startparser: still busy')
fp.fileno() # Test for file-ness
self.fp = fp
self.lineno = 0
@ -90,7 +90,7 @@ class EditableManPage(ScrolledText):
# End parsing -- must be busy, need not be at EOF
def _endparser(self):
if not self.busy():
raise RuntimeError, 'endparser: not busy'
raise RuntimeError('endparser: not busy')
if self.buffer:
self._parseline('')
try:

View file

@ -37,7 +37,7 @@ class ShellWindow(ScrolledText):
if not data:
self.tk.deletefilehandler(file)
pid, sts = os.waitpid(self.pid, 0)
print 'pid', pid, 'status', sts
print('pid', pid, 'status', sts)
self.pid = None
detail = sts>>8
cause = sts & 0xff

View file

@ -81,7 +81,7 @@ def go():
'',
-1,
'OK')
print 'pressed button', i
print('pressed button', i)
i = dialog(mainWidget,
'File Modified',
'File "tcl.h" has been modified since '
@ -92,7 +92,7 @@ def go():
'Save File',
'Discard Changes',
'Return To Editor')
print 'pressed button', i
print('pressed button', i)
def test():
import sys

View file

@ -28,7 +28,7 @@ def main():
try:
opts, args = getopt.getopt(sys.argv[1:], '')
except getopt.error as msg:
print msg
print(msg)
sys.exit(2)
for arg in args:
if arg[:1] == '+':
@ -278,8 +278,6 @@ def rescan():
scanbox.insert('end', line)
def scanfolder(folder = 'inbox', sequence = 'all'):
return map(
lambda line: line[:-1],
os.popen('scan +%s %s' % (folder, sequence), 'r').readlines())
return [line[:-1] for line in os.popen('scan +%s %s' % (folder, sequence), 'r').readlines()]
main()

View file

@ -134,7 +134,7 @@ def fillAppsMenu():
file_m_apps.add('command')
file_m_apps.delete(0, 'last')
names = root.winfo_interps()
names = map(None, names) # convert tuple to list
names = list(names) # convert tuple to list
names.sort()
for name in names:
try:

View file

@ -80,7 +80,7 @@ for s in (HEARTS, DIAMONDS):
for s in (CLUBS, SPADES):
COLOR[s] = BLACK
ALLSUITS = COLOR.keys()
ALLSUITS = list(COLOR.keys())
NSUITS = len(ALLSUITS)
@ -99,7 +99,7 @@ NVALUES = len(ALLVALUES)
# dummy element at index 0 so it can be indexed directly with the card
# value.
VALNAMES = ["", "A"] + map(str, range(2, 11)) + ["J", "Q", "K"]
VALNAMES = ["", "A"] + list(map(str, range(2, 11))) + ["J", "Q", "K"]
# Solitaire constants. The only one I can think of is the number of

View file

@ -344,7 +344,7 @@ def steps(here, there):
def interpolate(oldpts, newpts, n):
if len(oldpts) != len(newpts):
raise ValueError, "can't interpolate arrays of different length"
raise ValueError("can't interpolate arrays of different length")
pts = [0]*len(oldpts)
res = [tuple(oldpts)]
for i in range(1, n):

View file

@ -136,13 +136,13 @@ class Sheet:
return maxx, maxy
def reset(self):
for cell in self.cells.itervalues():
for cell in self.cells.values():
if hasattr(cell, 'reset'):
cell.reset()
def recalc(self):
self.reset()
for cell in self.cells.itervalues():
for cell in self.cells.values():
if hasattr(cell, 'recalc'):
cell.recalc(self.rexec)
@ -160,7 +160,7 @@ class Sheet:
full[0, y] = text, alignment = str(y), RIGHT
colwidth[0] = max(colwidth[0], len(text))
# Add sheet cells in columns with x>0 and y>0
for (x, y), cell in self.cells.iteritems():
for (x, y), cell in self.cells.items():
if x <= 0 or y <= 0:
continue
if hasattr(cell, 'recalc'):
@ -192,13 +192,13 @@ class Sheet:
if line:
line += '|'
line += text
print line
print(line)
if y == 0:
print sep
print(sep)
def xml(self):
out = ['<spreadsheet>']
for (x, y), cell in self.cells.iteritems():
for (x, y), cell in self.cells.items():
if hasattr(cell, 'xml'):
cellxml = cell.xml()
else:
@ -236,7 +236,7 @@ class SheetParser:
def startelement(self, tag, attrs):
method = getattr(self, 'start_'+tag, None)
if method:
for key, value in attrs.iteritems():
for key, value in attrs.items():
attrs[key] = str(value) # XXX Convert Unicode to 8-bit
method(attrs)
self.texts = []
@ -268,7 +268,7 @@ class SheetParser:
def end_long(self, text):
try:
self.value = long(text)
self.value = int(text)
except:
self.value = None
@ -325,7 +325,7 @@ class BaseCell:
class NumericCell(BaseCell):
def __init__(self, value, fmt="%s", alignment=RIGHT):
assert isinstance(value, (int, long, float, complex))
assert isinstance(value, (int, int, float, complex))
assert alignment in (LEFT, CENTER, RIGHT)
self.value = value
self.fmt = fmt
@ -366,7 +366,7 @@ class NumericCell(BaseCell):
class StringCell(BaseCell):
def __init__(self, text, fmt="%s", alignment=LEFT):
assert isinstance(text, (str, unicode))
assert isinstance(text, (str, str))
assert alignment in (LEFT, CENTER, RIGHT)
self.text = text
self.fmt = fmt
@ -699,7 +699,7 @@ class SheetGUI:
x1, x2 = x2, x1
if y1 > y2:
y1, y2 = y2, y1
for (x, y), cell in self.gridcells.iteritems():
for (x, y), cell in self.gridcells.items():
if x1 <= x <= x2 and y1 <= y <= y2:
cell['bg'] = 'lightBlue'
gridcell = self.gridcells.get(self.currentxy)
@ -735,7 +735,7 @@ class SheetGUI:
x1, x2 = x2, x1
if y1 > y2:
y1, y2 = y2, y1
for (x, y), cell in self.gridcells.iteritems():
for (x, y), cell in self.gridcells.items():
if x1 <= x <= x2 and y1 <= y <= y2:
cell['bg'] = 'white'
@ -775,7 +775,7 @@ class SheetGUI:
if text.startswith('='):
cell = FormulaCell(text[1:])
else:
for cls in int, long, float, complex:
for cls in int, int, float, complex:
try:
value = cls(text)
except:
@ -794,7 +794,7 @@ class SheetGUI:
def sync(self):
"Fill the GUI cells from the sheet cells."
self.sheet.recalc()
for (x, y), gridcell in self.gridcells.iteritems():
for (x, y), gridcell in self.gridcells.items():
if x == 0 or y == 0:
continue
cell = self.sheet.getcell(x, y)

View file

@ -5,7 +5,7 @@
from Tkinter import *
if TkVersion < 4.0:
raise ImportError, "This version of svkill requires Tk 4.0 or later"
raise ImportError("This version of svkill requires Tk 4.0 or later")
from string import splitfields
from string import split

View file

@ -172,8 +172,8 @@ class SelectionBox:
def updatelist(self):
key = self.entry.get()
ok = filter(lambda name, key=key, n=len(key): name[:n]==key,
self.choices)
ok = list(filter(lambda name, key=key, n=len(key): name[:n]==key,
self.choices))
if not ok:
self.frame.bell()
self.listbox.delete(0, AtEnd())
@ -205,7 +205,7 @@ class SelectionBox:
def search_string(self, search):
if not search:
self.frame.bell()
print 'Empty search string'
print('Empty search string')
return
if not self.casevar.get():
map = re.IGNORECASE
@ -218,7 +218,7 @@ class SelectionBox:
prog = re.compile(search)
except re.error as msg:
self.frame.bell()
print 'Regex error:', msg
print('Regex error:', msg)
return
here = self.text.index(AtInsert())
lineno = string.atoi(here[:string.find(here, '.')])

View file

@ -24,7 +24,7 @@ while 1:
try:
result = tk.call('eval', cmd)
except _tkinter.TclError as msg:
print 'TclError:', msg
print('TclError:', msg)
else:
if result: print result
if result: print(result)
cmd = ''

View file

@ -5,7 +5,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',

View file

@ -4,7 +4,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',

View file

@ -8,7 +8,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',

View file

@ -24,11 +24,11 @@ class App(Frame):
self.entrythingy.bind('<Key-Return>', self.print_something_else, "+")
def print_contents(self, event):
print "hi. contents of entry is now ---->", self.entrythingy.get()
print("hi. contents of entry is now ---->", self.entrythingy.get())
def print_something_else(self, event):
print "hi. Now doing something completely different"
print("hi. Now doing something completely different")
root = App()

View file

@ -4,7 +4,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',

View file

@ -7,7 +7,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT',

View file

@ -3,7 +3,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',
@ -28,14 +28,14 @@ class Test(Frame):
# is used for widgets. (remember, this is for ITEMS drawn
# on a canvas widget, not widgets)
option_value = self.drawing.itemconfig(pgon, "stipple")
print "pgon's current stipple value is -->", option_value[4], "<--"
print("pgon's current stipple value is -->", option_value[4], "<--")
option_value = self.drawing.itemconfig(pgon, "fill")
print "pgon's current fill value is -->", option_value[4], "<--"
print " when he is usually colored -->", option_value[3], "<--"
print("pgon's current fill value is -->", option_value[4], "<--")
print(" when he is usually colored -->", option_value[3], "<--")
## here we print out all the tags associated with this object
option_value = self.drawing.itemconfig(pgon, "tags")
print "pgon's tags are", option_value[4]
print("pgon's tags are", option_value[4])
self.drawing.pack(side=LEFT)

View file

@ -4,7 +4,7 @@ from Tkinter import *
class Test(Frame):
def printhi(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT', foreground='red',

View file

@ -7,7 +7,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.question = Label(self, text="Can Find The BLUE Square??????")
@ -46,8 +46,8 @@ class Test(Frame):
def scrollCanvasX(self, *args):
print "scrolling", args
print self.draw.scrollX.get()
print("scrolling", args)
print(self.draw.scrollX.get())
def __init__(self, master=None):

View file

@ -6,7 +6,7 @@ from Dialog import Dialog
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def makeWindow(self):
"""Create a top-level dialog with some buttons.

View file

@ -17,7 +17,7 @@ class App(Frame):
self.entrythingy.bind('<Key-Return>', self.print_contents)
def print_contents(self, event):
print "hi. contents of entry is now ---->", self.entrythingy.get()
print("hi. contents of entry is now ---->", self.entrythingy.get())
root = App()
root.master.title("Foo")

View file

@ -39,7 +39,7 @@ class App(Frame):
self.contents.set(str)
def print_contents(self, event):
print "hi. contents of entry is now ---->", self.contents.get()
print("hi. contents of entry is now ---->", self.contents.get())
root = App()
root.master.title("Foo")

View file

@ -7,11 +7,11 @@ from Tkinter import *
### ******* this isn't really called -- read the comments
def my_delete_callback():
print "whoops -- tried to delete me!"
print("whoops -- tried to delete me!")
class Test(Frame):
def deathHandler(self, event):
print self, "is now getting nuked. performing some save here...."
print(self, "is now getting nuked. performing some save here....")
def createWidgets(self):
# a hello button

View file

@ -35,13 +35,13 @@ from Tkinter import *
# some miscellaneous callbacks
def new_file():
print "opening new file"
print("opening new file")
def open_file():
print "opening OLD file"
print("opening OLD file")
def print_something():
print "picked a menu item"
print("picked a menu item")
@ -50,7 +50,7 @@ anchovies = 0
def print_anchovies():
global anchovies
anchovies = not anchovies
print "anchovies?", anchovies
print("anchovies?", anchovies)
def makeCommandMenu():
# make menu button

View file

@ -34,11 +34,11 @@ from Tkinter import *
def new_file():
print "opening new file"
print("opening new file")
def open_file():
print "opening OLD file"
print("opening OLD file")
def makeFileMenu():

View file

@ -8,7 +8,7 @@ def do_motion(event):
app.button.place(x=event.x, y=event.y)
def dothis():
print 'calling me!'
print('calling me!')
def createWidgets(top):
# make a frame. Note that the widget is 200 x 200

View file

@ -3,7 +3,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print self.hi_there["command"]
print(self.hi_there["command"])
def createWidgets(self):
# a hello button

View file

@ -6,7 +6,7 @@ def do_motion(event):
app.button.place(x=event.x, y=event.y)
def dothis():
print 'calling me!'
print('calling me!')
def createWidgets(top):
# make a frame. Note that the widget is 200 x 200

View file

@ -35,7 +35,7 @@ class Test(Frame):
# the "current" tag is applied to the object the cursor is over.
# this happens automatically.
self.draw.itemconfig(CURRENT, fill="red")
print self.draw.coords(CURRENT)
print(self.draw.coords(CURRENT))
def mouseLeave(self, event):
# the "current" tag is applied to the object the cursor is over.

View file

@ -12,7 +12,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):

View file

@ -2,7 +2,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT',

View file

@ -2,7 +2,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def createWidgets(self):
self.QUIT = Button(self, text='QUIT',

View file

@ -5,7 +5,7 @@ from Tkinter import *
class Test(Frame):
def print_value(self, val):
print "slider now at", val
print("slider now at", val)
def reset(self):
self.slider.set(0)

View file

@ -5,7 +5,7 @@ from Tkinter import *
class New_Button(Button):
def callback(self):
print self.counter
print(self.counter)
self.counter = self.counter + 1
def createWidgets(top):

View file

@ -75,9 +75,9 @@ def makeFlavors(var):
def printStuff():
print "party is", party.get()
print "flavor is", flavor.get()
print
print("party is", party.get())
print("flavor is", flavor.get())
print()
#################################################
#### Main starts here ...

View file

@ -5,7 +5,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def makeWindow(self):
fred = Toplevel()

View file

@ -4,7 +4,7 @@ from Tkinter import *
class Test(Frame):
def printit(self):
print "hi"
print("hi")
def makeWindow(self):
fred = Toplevel()

View file

@ -9,9 +9,9 @@ import sys
class QuitButton(Button):
def __init__(self, master, *args, **kwargs):
if not kwargs.has_key("text"):
if "text" not in kwargs:
kwargs["text"] = "QUIT"
if not kwargs.has_key("command"):
if "command" not in kwargs:
kwargs["command"] = master.quit
Button.__init__(self, master, *args, **kwargs)