Fix most trivially-findable print statements.

There's one major and one minor category still unfixed:
doctests are the major category (and I hope to be able to augment the
refactoring tool to refactor bona fide doctests soon);
other code generating print statements in strings is the minor category.

(Oh, and I don't know if the compiler package works.)
This commit is contained in:
Guido van Rossum 2007-02-09 05:37:30 +00:00
parent 452bf519a7
commit be19ed77dd
331 changed files with 2567 additions and 2648 deletions

View file

@ -104,7 +104,7 @@ def test():
fn = EasyDialogs.AskFileForOpen(message="Select an AIFF soundfile", typeList=("AIFF",))
if not fn: return
af = aifc.open(fn, 'r')
print af.getparams()
print(af.getparams())
p = Play_Audio_mac()
p.setoutrate(af.getframerate())
p.setsampwidth(af.getsampwidth())
@ -114,7 +114,7 @@ def test():
data = af.readframes(BUFSIZ)
if not data: break
p.writeframes(data)
print 'wrote', len(data), 'space', p.getfillable()
print('wrote', len(data), 'space', p.getfillable())
p.wait()
if __name__ == '__main__':

View file

@ -75,7 +75,7 @@ def Message(msg, id=260, ok=None):
_interact()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
return
h = d.GetDialogItemAsControl(2)
SetDialogItemText(h, lf2cr(msg))
@ -108,7 +108,7 @@ def AskString(prompt, default = "", id=261, ok=None, cancel=None):
_interact()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
return
h = d.GetDialogItemAsControl(3)
SetDialogItemText(h, lf2cr(prompt))
@ -150,7 +150,7 @@ def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
_interact()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
return
h = d.GetDialogItemAsControl(3)
SetDialogItemText(h, lf2cr(prompt))
@ -194,7 +194,7 @@ def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262
_interact()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
return
# Button assignments:
# 1 = default (invisible)
@ -429,7 +429,7 @@ def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfo
_interact()
d = GetNewDialog(id, -1)
if not d:
print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
print("EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)")
return
# h = d.GetDialogItemAsControl(3)
# SetDialogItemText(h, lf2cr(prompt))
@ -791,7 +791,7 @@ def test():
argv = GetArgv(optionlist=optionlist, commandlist=commandlist, addoldfile=0)
Message("Command line: %s"%' '.join(argv))
for i in range(len(argv)):
print 'arg[%d] = %r' % (i, argv[i])
print('arg[%d] = %r' % (i, argv[i]))
ok = AskYesNoCancel("Do you want to proceed?")
ok = AskYesNoCancel("Do you want to identify?", yes="Identify", no="No")
if ok > 0:

View file

@ -250,7 +250,7 @@ class Application:
if window in self._windows:
self._windows[window].do_itemhit(item, event)
else:
print 'Dialog event for unknown dialog'
print('Dialog event for unknown dialog')
return 1
return 0
@ -323,14 +323,14 @@ class Application:
def do_unknownpartcode(self, partcode, window, event):
(what, message, when, where, modifiers) = event
if DEBUG: print "Mouse down at global:", where
if DEBUG: print "\tUnknown part code:", partcode
if DEBUG: print "\tEvent:", self.printevent(event)
if DEBUG: print("Mouse down at global:", where)
if DEBUG: print("\tUnknown part code:", partcode)
if DEBUG: print("\tEvent:", self.printevent(event))
if hasattr(MacOS, 'HandleEvent'):
MacOS.HandleEvent(event)
def do_unknownwindow(self, partcode, window, event):
if DEBUG: print 'Unknown window:', window
if DEBUG: print('Unknown window:', window)
if hasattr(MacOS, 'HandleEvent'):
MacOS.HandleEvent(event)
@ -373,7 +373,7 @@ class Application:
# else it wasn't for us, sigh...
def do_char(self, c, event):
if DEBUG: print "Character", repr(c)
if DEBUG: print("Character", repr(c))
def do_updateEvt(self, event):
(what, message, when, where, modifiers) = event
@ -402,7 +402,7 @@ class Application:
self.do_suspendresume(event)
else:
if DEBUG:
print 'unknown osEvt:',
print('unknown osEvt:', end=' ')
self.printevent(event)
def do_suspendresume(self, event):
@ -415,7 +415,7 @@ class Application:
def do_kHighLevelEvent(self, event):
(what, message, when, where, modifiers) = event
if DEBUG:
print "High Level Event:",
print("High Level Event:", end=' ')
self.printevent(event)
try:
AEProcessAppleEvent(event)
@ -426,7 +426,7 @@ class Application:
def do_unknownevent(self, event):
if DEBUG:
print "Unhandled event:",
print("Unhandled event:", end=' ')
self.printevent(event)
def printevent(self, event):
@ -434,13 +434,13 @@ class Application:
nicewhat = repr(what)
if what in eventname:
nicewhat = eventname[what]
print nicewhat,
print(nicewhat, end=' ')
if what == kHighLevelEvent:
h, v = where
print repr(ostypecode(message)), hex(when), repr(ostypecode(h | (v<<16))),
print(repr(ostypecode(message)), hex(when), repr(ostypecode(h | (v<<16))), end=' ')
else:
print hex(message), hex(when), where,
print hex(modifiers)
print(hex(message), hex(when), where, end=' ')
print(hex(modifiers))
class MenuBar:
@ -477,7 +477,7 @@ class MenuBar:
def addmenu(self, title, after = 0, id=None):
if id == None:
id = self.getnextid()
if DEBUG: print 'Newmenu', title, id # XXXX
if DEBUG: print('Newmenu', title, id) # XXXX
m = NewMenu(id, title)
m.InsertMenu(after)
if after >= 0:
@ -488,7 +488,7 @@ class MenuBar:
return id, m
def delmenu(self, id):
if DEBUG: print 'Delmenu', id # XXXX
if DEBUG: print('Delmenu', id) # XXXX
DeleteMenu(id)
def addpopup(self, title = ''):
@ -531,8 +531,8 @@ class MenuBar:
if id in self.menus:
self.menus[id].dispatch(id, item, window, event)
else:
if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \
(id, item, window, event)
if DEBUG: print("MenuBar.dispatch(%d, %d, %s, %s)" % \
(id, item, window, event))
# XXX Need a way to get menus as resources and bind them to callbacks
@ -837,10 +837,10 @@ class Window:
def do_contentclick(self, local, modifiers, event):
if DEBUG:
print 'Click in contents at %s, modifiers %s'%(local, modifiers)
print('Click in contents at %s, modifiers %s'%(local, modifiers))
def do_rawupdate(self, window, event):
if DEBUG: print "raw update for", window
if DEBUG: print("raw update for", window)
SetPort(window)
window.BeginUpdate()
self.do_update(window, event)
@ -857,12 +857,12 @@ class Window:
EraseRgn(window.GetWindowPort().visRgn)
def do_activate(self, activate, event):
if DEBUG: print 'Activate %d for %s'%(activate, self.wid)
if DEBUG: print('Activate %d for %s'%(activate, self.wid))
class ControlsWindow(Window):
def do_rawupdate(self, window, event):
if DEBUG: print "raw update for", window
if DEBUG: print("raw update for", window)
SetPort(window)
window.BeginUpdate()
self.do_update(window, event)
@ -872,7 +872,7 @@ class ControlsWindow(Window):
window.EndUpdate()
def do_controlhit(self, window, control, pcode, event):
if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode
if DEBUG: print("control hit in", window, "on", control, "; pcode =", pcode)
def do_inContent(self, partcode, window, event):
if MyFrontWindow() != window:
@ -885,8 +885,8 @@ class ControlsWindow(Window):
if pcode and control:
self.do_rawcontrolhit(window, control, pcode, local, event)
else:
if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \
(local, window, pcode, control)
if DEBUG: print("FindControl(%s, %s) -> (%s, %s)" % \
(local, window, pcode, control))
self.do_contentclick(local, modifiers, event)
def do_rawcontrolhit(self, window, control, pcode, local, event):
@ -975,11 +975,11 @@ class ScrolledWindow(ControlsWindow):
pcode = control.TrackControl(local)
if pcode == inThumb:
value = control.GetControlValue()
print 'setbars', which, value #DBG
print('setbars', which, value) #DBG
self.scrollbar_callback(which, 'set', value)
self.updatescrollbars()
else:
print 'funny part', pcode #DBG
print('funny part', pcode) #DBG
return 1
def do_controltrack(self, control, pcode):
@ -1045,7 +1045,7 @@ class ScrolledWindow(ControlsWindow):
return 0, 0
def scrollbar_callback(self, which, what, value):
print 'scroll', which, what, value
print('scroll', which, what, value)
class DialogWindow(Window):
"""A modeless dialog window"""
@ -1063,7 +1063,7 @@ class DialogWindow(Window):
Window.do_postclose(self)
def do_itemhit(self, item, event):
print 'Dialog %s, item %d hit'%(self.dlg, item)
print('Dialog %s, item %d hit'%(self.dlg, item))
def do_rawupdate(self, window, event):
pass
@ -1096,7 +1096,7 @@ class TestApp(Application):
self.quititem = MenuItem(m, "Quit", "Q", self.quit)
def save(self, *args):
print "Save"
print("Save")
def quit(self, *args):
raise self
@ -1106,7 +1106,7 @@ class TestApp(Application):
self.nohelpitem = MenuItem(hm, "There isn't any", None, self.nohelp)
def nohelp(self, *args):
print "I told you there isn't any!"
print("I told you there isn't any!")
def debug(self, *args):
import pdb

View file

@ -71,8 +71,8 @@ class MiniApplication:
try:
AE.AEProcessAppleEvent(event)
except AE.Error as err:
print 'AE error: ', err
print 'in', msg
print('AE error: ', err)
print('in', msg)
traceback.print_exc()
return
elif what == keyDown:
@ -107,7 +107,7 @@ class MiniApplication:
if hasattr(MacOS, 'HandleEvent'):
MacOS.HandleEvent(event)
else:
print "Unhandled event:", event
print("Unhandled event:", event)
def getabouttext(self):
return self.__class__.__name__
@ -191,7 +191,7 @@ class _Test(AEServer, MiniApplication):
pass
def other(self, _object=None, _class=None, _type=None, **args):
print 'AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
print('AppleEvent', (_class, _type), 'for', _object, 'Other args:', args)
if __name__ == '__main__':

View file

@ -349,15 +349,15 @@ def test():
target = AE.AECreateDesc('sign', 'quil')
ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0)
print unpackevent(ae)
print(unpackevent(ae))
raw_input(":")
ae = AE.AECreateAppleEvent('core', 'getd', target, -1, 0)
obj = Character(2, Word(1, Document(1)))
print obj
print repr(obj)
print(obj)
print(repr(obj))
packevent(ae, {'----': obj})
params, attrs = unpackevent(ae)
print params['----']
print(params['----'])
raw_input(":")
if __name__ == '__main__':

View file

@ -51,9 +51,9 @@ class AppleSingle(object):
except ValueError as arg:
raise Error, "Unpack header error: %s" % (arg,)
if verbose:
print 'Magic: 0x%8.8x' % (magic,)
print 'Version: 0x%8.8x' % (version,)
print 'Entries: %d' % (nentry,)
print('Magic: 0x%8.8x' % (magic,))
print('Version: 0x%8.8x' % (version,))
print('Entries: %d' % (nentry,))
if magic != AS_MAGIC:
raise Error, "Unknown AppleSingle magic number 0x%8.8x" % (magic,)
if version != AS_VERSION:
@ -68,7 +68,7 @@ class AppleSingle(object):
except ValueError as arg:
raise Error, "Unpack entry error: %s" % (arg,)
if verbose:
print "Fork %d, offset %d, length %d" % (restype, offset, length)
print("Fork %d, offset %d, length %d" % (restype, offset, length))
fileobj.seek(offset)
data = fileobj.read(length)
if len(data) != length:
@ -124,7 +124,7 @@ def decode(infile, outpath, resonly=False, verbose=False):
def _test():
if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4:
print 'Usage: applesingle.py [-r] applesinglefile decodedfile'
print('Usage: applesingle.py [-r] applesinglefile decodedfile')
sys.exit(1)
if sys.argv[1] == '-r':
resonly = True

View file

@ -37,7 +37,7 @@ class ArgvCollector:
self._dooneevent(mask, timeout)
if not self.quitting:
print "argvemulator: timeout waiting for arguments"
print("argvemulator: timeout waiting for arguments")
self.close()
@ -54,12 +54,12 @@ class ArgvCollector:
AE.AEProcessAppleEvent(event)
except AE.Error as err:
msg = "High Level Event: %r %r" % (hex(message), hex(h | (v<<16)))
print 'AE error: ', err
print 'in', msg
print('AE error: ', err)
print('in', msg)
traceback.print_exc()
return
else:
print "Unhandled event:", event
print("Unhandled event:", event)
def _quit(self):
@ -78,7 +78,7 @@ class ArgvCollector:
pathname = fsref.as_pathname()
sys.argv.append(pathname)
except Exception as e:
print "argvemulator.py warning: can't unpack an open document event"
print("argvemulator.py warning: can't unpack an open document event")
import traceback
traceback.print_exc()
@ -86,4 +86,4 @@ class ArgvCollector:
if __name__ == '__main__':
ArgvCollector().mainloop()
print "sys.argv=", sys.argv
print("sys.argv=", sys.argv)

View file

@ -831,8 +831,8 @@ Options:
def usage(msg=None):
if msg:
print msg
print cmdline_doc
print(msg)
print(cmdline_doc)
sys.exit(1)
def main(builder=None):

View file

@ -695,76 +695,76 @@ def emptytrash():
def _test():
import EasyDialogs
print 'Original findertools functionality test...'
print 'Testing launch...'
print('Original findertools functionality test...')
print('Testing launch...')
pathname = EasyDialogs.AskFileForOpen('File to launch:')
if pathname:
result = launch(pathname)
if result:
print 'Result: ', result
print 'Press return-',
print('Result: ', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing print...'
print('Testing print...')
pathname = EasyDialogs.AskFileForOpen('File to print:')
if pathname:
result = Print(pathname)
if result:
print 'Result: ', result
print 'Press return-',
print('Result: ', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing copy...'
print('Testing copy...')
pathname = EasyDialogs.AskFileForOpen('File to copy:')
if pathname:
destdir = EasyDialogs.AskFolder('Destination:')
if destdir:
result = copy(pathname, destdir)
if result:
print 'Result:', result
print 'Press return-',
print('Result:', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing move...'
print('Testing move...')
pathname = EasyDialogs.AskFileForOpen('File to move:')
if pathname:
destdir = EasyDialogs.AskFolder('Destination:')
if destdir:
result = move(pathname, destdir)
if result:
print 'Result:', result
print 'Press return-',
print('Result:', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing sleep...'
print('Testing sleep...')
if EasyDialogs.AskYesNoCancel('Sleep?') > 0:
result = sleep()
if result:
print 'Result:', result
print 'Press return-',
print('Result:', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing shutdown...'
print('Testing shutdown...')
if EasyDialogs.AskYesNoCancel('Shut down?') > 0:
result = shutdown()
if result:
print 'Result:', result
print 'Press return-',
print('Result:', result)
print('Press return-', end=' ')
sys.stdin.readline()
print 'Testing restart...'
print('Testing restart...')
if EasyDialogs.AskYesNoCancel('Restart?') > 0:
result = restart()
if result:
print 'Result:', result
print 'Press return-',
print('Result:', result)
print('Press return-', end=' ')
sys.stdin.readline()
def _test2():
print '\nmorefindertools version %s\nTests coming up...' %__version__
print('\nmorefindertools version %s\nTests coming up...' %__version__)
import os
import random
# miscellaneous
print '\tfilesharing on?', filesharing() # is file sharing on, off, starting up?
print '\tOS version', OSversion() # the version of the system software
print('\tfilesharing on?', filesharing()) # is file sharing on, off, starting up?
print('\tOS version', OSversion()) # the version of the system software
# set the soundvolume in a simple way
print '\tSystem beep volume'
print('\tSystem beep volume')
for i in range(0, 7):
volumelevel(i)
MacOS.SysBeep()
@ -781,10 +781,10 @@ def _test2():
windowview(base, 1) # set the view by list
label(f, 2) # set the label of this file to something orange
print '\tlabel', label(f) # get the label of this file
print('\tlabel', label(f)) # get the label of this file
# the file location only works in a window with icon view!
print 'Random locations for an icon'
print('Random locations for an icon')
windowview(base, 0) # set the view by icon
windowsize(base, (600, 600))
for i in range(50):
@ -794,36 +794,36 @@ def _test2():
windowview(base, 1) # set the view by icon
orgpos = windowposition(base)
print 'Animated window location'
print('Animated window location')
for i in range(10):
pos = (100+i*10, 100+i*10)
windowposition(base, pos)
print '\twindow position', pos
print('\twindow position', pos)
windowposition(base, orgpos) # park it where it was before
print 'Put a comment in file', f, ':'
print '\t', comment(f) # print the Finder comment this file has
print('Put a comment in file', f, ':')
print('\t', comment(f)) # print the Finder comment this file has
s = 'This is a comment no one reads!'
comment(f, s) # set the Finder comment
def _test3():
print 'MacOS9 or better specific functions'
print('MacOS9 or better specific functions')
# processes
pr = processes() # return a list of tuples with (active_processname, creatorcode)
print 'Return a list of current active processes:'
print('Return a list of current active processes:')
for p in pr:
print '\t', p
print('\t', p)
# get attributes of the first process in the list
print 'Attributes of the first process in the list:'
print('Attributes of the first process in the list:')
pinfo = processinfo(pr[0][0])
print '\t', pr[0][0]
print '\t\tmemory partition', pinfo.partition # the memory allocated to this process
print '\t\tmemory used', pinfo.used # the memory actuall used by this process
print '\t\tis visible', pinfo.visible # is the process visible to the user
print '\t\tis frontmost', pinfo.frontmost # is the process the front most one?
print '\t\thas scripting', pinfo.hasscripting # is the process scriptable?
print '\t\taccepts high level events', pinfo.accepthighlevel # does the process accept high level appleevents?
print('\t', pr[0][0])
print('\t\tmemory partition', pinfo.partition) # the memory allocated to this process
print('\t\tmemory used', pinfo.used) # the memory actuall used by this process
print('\t\tis visible', pinfo.visible) # is the process visible to the user
print('\t\tis frontmost', pinfo.frontmost) # is the process the front most one?
print('\t\thas scripting', pinfo.hasscripting) # is the process scriptable?
print('\t\taccepts high level events', pinfo.accepthighlevel) # does the process accept high level appleevents?
if __name__ == '__main__':
_test()

View file

@ -115,8 +115,8 @@ def main_interactive(interact=0, basepkgname='StdSuites'):
processfile(filename, edit_modnames=edit_modnames, basepkgname=basepkgname,
verbose=sys.stderr)
except MacOS.Error as arg:
print "Error getting terminology:", arg
print "Retry, manually parsing resources"
print("Error getting terminology:", arg)
print("Retry, manually parsing resources")
processfile_fromresource(filename, edit_modnames=edit_modnames,
basepkgname=basepkgname, verbose=sys.stderr)
@ -145,10 +145,10 @@ def processfile_fromresource(fullname, output=None, basepkgname=None,
edit_modnames=None, creatorsignature=None, dump=None, verbose=None):
"""Process all resources in a single file"""
if not is_scriptable(fullname) and verbose:
print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
print("Warning: app does not seem scriptable: %s" % fullname, file=verbose)
cur = CurResFile()
if verbose:
print >>verbose, "Processing", fullname
print("Processing", fullname, file=verbose)
rf = macresource.open_pathname(fullname)
try:
UseResFile(rf)
@ -160,11 +160,11 @@ def processfile_fromresource(fullname, output=None, basepkgname=None,
res = Get1IndResource('aeut', 1+i)
resources.append(res)
if verbose:
print >>verbose, "\nLISTING aete+aeut RESOURCES IN", repr(fullname)
print("\nLISTING aete+aeut RESOURCES IN", repr(fullname), file=verbose)
aetelist = []
for res in resources:
if verbose:
print >>verbose, "decoding", res.GetResInfo(), "..."
print("decoding", res.GetResInfo(), "...", file=verbose)
data = res.data
aete = decode(data, verbose)
aetelist.append((aete, res.GetResInfo()))
@ -185,15 +185,15 @@ def processfile(fullname, output=None, basepkgname=None,
verbose=None):
"""Ask an application for its terminology and process that"""
if not is_scriptable(fullname) and verbose:
print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
print("Warning: app does not seem scriptable: %s" % fullname, file=verbose)
if verbose:
print >>verbose, "\nASKING FOR aete DICTIONARY IN", repr(fullname)
print("\nASKING FOR aete DICTIONARY IN", repr(fullname), file=verbose)
try:
aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
except MacOS.Error as arg:
if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
if verbose:
print >>verbose, "GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually"
print("GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually", file=verbose)
aedata, sig = getappterminology(fullname, verbose=verbose)
if not creatorsignature:
creatorsignature = sig
@ -202,15 +202,15 @@ def processfile(fullname, output=None, basepkgname=None,
else:
if launched:
if verbose:
print >>verbose, "Launched", fullname
print("Launched", fullname, file=verbose)
raw = aetools.unpack(aedescobj)
if not raw:
if verbose:
print >>verbose, 'Unpack returned empty value:', raw
print('Unpack returned empty value:', raw, file=verbose)
return
if not raw[0].data:
if verbose:
print >>verbose, 'Unpack returned value without data:', raw
print('Unpack returned value without data:', raw, file=verbose)
return
aedata = raw[0]
aete = decode(aedata.data, verbose)
@ -246,7 +246,7 @@ def getappterminology(fullname, verbose=None):
talker._start()
except (MacOS.Error, aetools.Error) as arg:
if verbose:
print >>verbose, 'Warning: start() failed, continuing anyway:', arg
print('Warning: start() failed, continuing anyway:', arg, file=verbose)
reply = talker.send("ascr", "gdte")
#reply2 = talker.send("ascr", "gdut")
# Now pick the bits out of the return that we need.
@ -344,9 +344,9 @@ def getlist(f, description, getitem):
return list
def alt_generic(what, f, *args):
print "generic", repr(what), args
print("generic", repr(what), args)
res = vageneric(what, f, args)
print '->', repr(res)
print('->', repr(res))
return res
def generic(what, f, *args):
@ -940,14 +940,14 @@ class ObjectCompiler:
for mapper in self.othernamemappers:
if mapper.hasname(name) and mapper.modulename != self.modulename:
if self.verbose:
print >>self.verbose, "Duplicate Python identifier:", name, self.modulename, mapper.modulename
print("Duplicate Python identifier:", name, self.modulename, mapper.modulename, file=self.verbose)
return True
return False
def askdefinitionmodule(self, type, code):
if not self.can_interact:
if self.verbose:
print >>self.verbose, "** No definition for %s '%s' found" % (type, code)
print("** No definition for %s '%s' found" % (type, code), file=self.verbose)
return None
path = EasyDialogs.AskFileForSave(message='Where is %s %s declared?'%(type, code))
if not path: return
@ -1018,7 +1018,7 @@ class ObjectCompiler:
if self.fp and (elements or len(properties) > 1 or (len(properties) == 1 and
properties[0][1] != 'c@#!')):
if self.verbose:
print >>self.verbose, '** Skip multiple %s of %s (code %r)' % (cname, self.namemappers[0].findcodename('class', code)[0], code)
print('** Skip multiple %s of %s (code %r)' % (cname, self.namemappers[0].findcodename('class', code)[0], code), file=self.verbose)
raise RuntimeError, "About to skip non-empty class"
return
plist = []

View file

@ -94,7 +94,7 @@ def _code_fontrecord(data, key):
chr(0) + _code_default(name)
def _code_boolean(data, key):
print 'XXXX boolean:', repr(data)
print('XXXX boolean:', repr(data))
return chr(data)
def _code_text(data, key):
@ -258,7 +258,7 @@ def _test():
v = ic[k]
except error:
v = '????'
print k, '\t', v
print(k, '\t', v)
sys.exit(1)
if __name__ == '__main__':

View file

@ -140,7 +140,7 @@ def _decode(pathname, verbose=0):
import tempfile
fd, newpathname = tempfile.mkstemp(".rsrc")
if verbose:
print 'Decoding', pathname, 'to', newpathname
print('Decoding', pathname, 'to', newpathname)
import applesingle
applesingle.decode(pathname, newpathname, resonly=1)
return newpathname

View file

@ -229,7 +229,7 @@ class PimpTarUnpacker(PimpUnpacker):
#print 'SKIP', member.name
else:
member.name = newprefix + member.name[len(oldprefix):]
print ' ', member.name
print(' ', member.name)
break
elif oldprefix2 and member.name[:len(oldprefix2)] == oldprefix2:
if newprefix is None:
@ -1020,8 +1020,8 @@ def _run(mode, verbose, force, args, prefargs, watcher):
elif mode =='list':
if not args:
args = db.listnames()
print "%-20.20s\t%s" % ("Package", "Description")
print
print("%-20.20s\t%s" % ("Package", "Description"))
print()
for pkgname in args:
pkg = db.find(pkgname)
if pkg:
@ -1029,21 +1029,21 @@ def _run(mode, verbose, force, args, prefargs, watcher):
pkgname = pkg.fullname()
else:
description = 'Error: no such package'
print "%-20.20s\t%s" % (pkgname, description)
print("%-20.20s\t%s" % (pkgname, description))
if verbose:
print "\tHome page:\t", pkg.homepage()
print("\tHome page:\t", pkg.homepage())
try:
print "\tDownload URL:\t", pkg.downloadURL()
print("\tDownload URL:\t", pkg.downloadURL())
except KeyError:
pass
description = pkg.description()
description = '\n\t\t\t\t\t'.join(description.splitlines())
print "\tDescription:\t%s" % description
print("\tDescription:\t%s" % description)
elif mode =='status':
if not args:
args = db.listnames()
print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message")
print
print("%-20.20s\t%s\t%s" % ("Package", "Installed", "Message"))
print()
for pkgname in args:
pkg = db.find(pkgname)
if pkg:
@ -1052,7 +1052,7 @@ def _run(mode, verbose, force, args, prefargs, watcher):
else:
status = 'error'
msg = 'No such package'
print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg)
print("%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg))
if verbose and status == "no":
prereq = pkg.prerequisites()
for pkg, msg in prereq:
@ -1060,22 +1060,22 @@ def _run(mode, verbose, force, args, prefargs, watcher):
pkg = ''
else:
pkg = pkg.fullname()
print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg)
print("%-20.20s\tRequirement: %s %s" % ("", pkg, msg))
elif mode == 'install':
if not args:
print 'Please specify packages to install'
print('Please specify packages to install')
sys.exit(1)
inst = PimpInstaller(db)
for pkgname in args:
pkg = db.find(pkgname)
if not pkg:
print '%s: No such package' % pkgname
print('%s: No such package' % pkgname)
continue
list, messages = inst.prepareInstall(pkg, force)
if messages and not force:
print "%s: Not installed:" % pkgname
print("%s: Not installed:" % pkgname)
for m in messages:
print "\t", m
print("\t", m)
else:
if verbose:
output = sys.stdout
@ -1083,26 +1083,26 @@ def _run(mode, verbose, force, args, prefargs, watcher):
output = None
messages = inst.install(list, output)
if messages:
print "%s: Not installed:" % pkgname
print("%s: Not installed:" % pkgname)
for m in messages:
print "\t", m
print("\t", m)
def main():
"""Minimal commandline tool to drive pimp."""
import getopt
def _help():
print "Usage: pimp [options] -s [package ...] List installed status"
print " pimp [options] -l [package ...] Show package information"
print " pimp [options] -i package ... Install packages"
print " pimp -d Dump database to stdout"
print " pimp -V Print version number"
print "Options:"
print " -v Verbose"
print " -f Force installation"
print " -D dir Set destination directory"
print " (default: %s)" % DEFAULT_INSTALLDIR
print " -u url URL for database"
print("Usage: pimp [options] -s [package ...] List installed status")
print(" pimp [options] -l [package ...] Show package information")
print(" pimp [options] -i package ... Install packages")
print(" pimp -d Dump database to stdout")
print(" pimp -V Print version number")
print("Options:")
print(" -v Verbose")
print(" -f Force installation")
print(" -D dir Set destination directory")
print(" (default: %s)" % DEFAULT_INSTALLDIR)
print(" -u url URL for database")
sys.exit(1)
class _Watcher:
@ -1152,7 +1152,7 @@ def main():
if not mode:
_help()
if mode == 'version':
print 'Pimp version %s; module name is %s' % (PIMP_VERSION, __name__)
print('Pimp version %s; module name is %s' % (PIMP_VERSION, __name__))
else:
_run(mode, verbose, force, args, prefargs, watcher)

View file

@ -272,8 +272,8 @@ def _test():
fname = 'frame%04.4d.jpg'%num
num = num+1
pname = os.path.join(dstdir, fname)
if not img: print 'Not',
print 'Writing %s, size %dx%d, %d bytes'%(fname, imgw, imgh, len(data))
if not img: print('Not', end=' ')
print('Writing %s, size %dx%d, %d bytes'%(fname, imgw, imgh, len(data)))
if img:
wrt = img.writer(imgfmt, pname)
wrt.width = imgw
@ -282,9 +282,9 @@ def _test():
timestamp, data = rdr.ReadVideo()
MacOS.SetCreatorAndType(pname, 'ogle', 'JPEG')
if num > 20:
print 'stopping at 20 frames so your disk does not fill up:-)'
print('stopping at 20 frames so your disk does not fill up:-)')
break
print 'Total frames:', num
print('Total frames:', num)
if __name__ == '__main__':
_test()