Run 2to3's print fixer over some places that had been missed.

This commit is contained in:
Collin Winter 2007-08-30 18:39:28 +00:00
parent 716c3ac40c
commit e7bf59f500
51 changed files with 253 additions and 253 deletions

View File

@ -336,16 +336,16 @@ def parseOptions(args=None):
options, args = getopt.getopt(args, '?hb', options, args = getopt.getopt(args, '?hb',
[ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir=']) [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir='])
except getopt.error as msg: except getopt.error as msg:
print msg print(msg)
sys.exit(1) sys.exit(1)
if args: if args:
print "Additional arguments" print("Additional arguments")
sys.exit(1) sys.exit(1)
for k, v in options: for k, v in options:
if k in ('-h', '-?'): if k in ('-h', '-?'):
print USAGE print(USAGE)
sys.exit(0) sys.exit(0)
elif k in ('-d', '--build-dir'): elif k in ('-d', '--build-dir'):
@ -368,12 +368,12 @@ def parseOptions(args=None):
SDKPATH=os.path.abspath(SDKPATH) SDKPATH=os.path.abspath(SDKPATH)
DEPSRC=os.path.abspath(DEPSRC) DEPSRC=os.path.abspath(DEPSRC)
print "Settings:" print("Settings:")
print " * Source directory:", SRCDIR print(" * Source directory:", SRCDIR)
print " * Build directory: ", WORKDIR print(" * Build directory: ", WORKDIR)
print " * SDK location: ", SDKPATH print(" * SDK location: ", SDKPATH)
print " * third-party source:", DEPSRC print(" * third-party source:", DEPSRC)
print "" print("")
@ -440,7 +440,7 @@ def downloadURL(url, fname):
pass pass
else: else:
if KNOWNSIZES.get(url) == size: if KNOWNSIZES.get(url) == size:
print "Using existing file for", url print("Using existing file for", url)
return return
fpIn = urllib2.urlopen(url) fpIn = urllib2.urlopen(url)
fpOut = open(fname, 'wb') fpOut = open(fname, 'wb')
@ -479,14 +479,14 @@ def buildRecipe(recipe, basedir, archList):
if os.path.exists(sourceArchive): if os.path.exists(sourceArchive):
print "Using local copy of %s"%(name,) print("Using local copy of %s"%(name,))
else: else:
print "Downloading %s"%(name,) print("Downloading %s"%(name,))
downloadURL(url, sourceArchive) downloadURL(url, sourceArchive)
print "Archive for %s stored as %s"%(name, sourceArchive) print("Archive for %s stored as %s"%(name, sourceArchive))
print "Extracting archive for %s"%(name,) print("Extracting archive for %s"%(name,))
buildDir=os.path.join(WORKDIR, '_bld') buildDir=os.path.join(WORKDIR, '_bld')
if not os.path.exists(buildDir): if not os.path.exists(buildDir):
os.mkdir(buildDir) os.mkdir(buildDir)
@ -549,14 +549,14 @@ def buildRecipe(recipe, basedir, archList):
configure_args.insert(0, configure) configure_args.insert(0, configure)
configure_args = [ shellQuote(a) for a in configure_args ] configure_args = [ shellQuote(a) for a in configure_args ]
print "Running configure for %s"%(name,) print("Running configure for %s"%(name,))
runCommand(' '.join(configure_args) + ' 2>&1') runCommand(' '.join(configure_args) + ' 2>&1')
print "Running install for %s"%(name,) print("Running install for %s"%(name,))
runCommand('{ ' + install + ' ;} 2>&1') runCommand('{ ' + install + ' ;} 2>&1')
print "Done %s"%(name,) print("Done %s"%(name,))
print "" print("")
os.chdir(curdir) os.chdir(curdir)
@ -564,9 +564,9 @@ def buildLibraries():
""" """
Build our dependencies into $WORKDIR/libraries/usr/local Build our dependencies into $WORKDIR/libraries/usr/local
""" """
print "" print("")
print "Building required libraries" print("Building required libraries")
print "" print("")
universal = os.path.join(WORKDIR, 'libraries') universal = os.path.join(WORKDIR, 'libraries')
os.mkdir(universal) os.mkdir(universal)
os.makedirs(os.path.join(universal, 'usr', 'local', 'lib')) os.makedirs(os.path.join(universal, 'usr', 'local', 'lib'))
@ -580,7 +580,7 @@ def buildLibraries():
def buildPythonDocs(): def buildPythonDocs():
# This stores the documentation as Resources/English.lproj/Docuentation # This stores the documentation as Resources/English.lproj/Docuentation
# inside the framwork. pydoc and IDLE will pick it up there. # inside the framwork. pydoc and IDLE will pick it up there.
print "Install python documentation" print("Install python documentation")
rootDir = os.path.join(WORKDIR, '_root') rootDir = os.path.join(WORKDIR, '_root')
version = getVersion() version = getVersion()
docdir = os.path.join(rootDir, 'pydocs') docdir = os.path.join(rootDir, 'pydocs')
@ -588,13 +588,13 @@ def buildPythonDocs():
name = 'html-%s.tar.bz2'%(getFullVersion(),) name = 'html-%s.tar.bz2'%(getFullVersion(),)
sourceArchive = os.path.join(DEPSRC, name) sourceArchive = os.path.join(DEPSRC, name)
if os.path.exists(sourceArchive): if os.path.exists(sourceArchive):
print "Using local copy of %s"%(name,) print("Using local copy of %s"%(name,))
else: else:
print "Downloading %s"%(name,) print("Downloading %s"%(name,))
downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%( downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%(
getFullVersion(), name), sourceArchive) getFullVersion(), name), sourceArchive)
print "Archive for %s stored as %s"%(name, sourceArchive) print("Archive for %s stored as %s"%(name, sourceArchive))
extractArchive(os.path.dirname(docdir), sourceArchive) extractArchive(os.path.dirname(docdir), sourceArchive)
os.rename( os.rename(
@ -604,7 +604,7 @@ def buildPythonDocs():
def buildPython(): def buildPython():
print "Building a universal python" print("Building a universal python")
buildDir = os.path.join(WORKDIR, '_bld', 'python') buildDir = os.path.join(WORKDIR, '_bld', 'python')
rootDir = os.path.join(WORKDIR, '_root') rootDir = os.path.join(WORKDIR, '_root')
@ -627,24 +627,24 @@ def buildPython():
# several paths. # several paths.
version = getVersion() version = getVersion()
print "Running configure..." print("Running configure...")
runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%( runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%(
shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(os.path.join(SRCDIR, 'configure')),
shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1], shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1],
shellQuote(WORKDIR)[1:-1])) shellQuote(WORKDIR)[1:-1]))
print "Running make" print("Running make")
runCommand("make") runCommand("make")
print "Running make frameworkinstall" print("Running make frameworkinstall")
runCommand("make frameworkinstall DESTDIR=%s"%( runCommand("make frameworkinstall DESTDIR=%s"%(
shellQuote(rootDir))) shellQuote(rootDir)))
print "Running make frameworkinstallextras" print("Running make frameworkinstallextras")
runCommand("make frameworkinstallextras DESTDIR=%s"%( runCommand("make frameworkinstallextras DESTDIR=%s"%(
shellQuote(rootDir))) shellQuote(rootDir)))
print "Copying required shared libraries" print("Copying required shared libraries")
if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
runCommand("mv %s/* %s"%( runCommand("mv %s/* %s"%(
shellQuote(os.path.join( shellQuote(os.path.join(
@ -655,7 +655,7 @@ def buildPython():
'Python.framework', 'Versions', getVersion(), 'Python.framework', 'Versions', getVersion(),
'lib')))) 'lib'))))
print "Fix file modes" print("Fix file modes")
frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
gid = grp.getgrnam('admin').gr_gid gid = grp.getgrnam('admin').gr_gid
@ -744,7 +744,7 @@ def packageFromRecipe(targetDir, recipe):
readme = textwrap.dedent(recipe['readme']) readme = textwrap.dedent(recipe['readme'])
isRequired = recipe.get('required', True) isRequired = recipe.get('required', True)
print "- building package %s"%(pkgname,) print("- building package %s"%(pkgname,))
# Substitute some variables # Substitute some variables
textvars = dict( textvars = dict(
@ -1047,9 +1047,9 @@ def main():
shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt')) shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt'))
fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w') fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
print >> fp, "# BUILD INFO" print("# BUILD INFO", file=fp)
print >> fp, "# Date:", time.ctime() print("# Date:", time.ctime(), file=fp)
print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos print("# By:", pwd.getpwuid(os.getuid()).pw_gecos, file=fp)
fp.close() fp.close()
# Custom icon for the DMG, shown when the DMG is mounted. # Custom icon for the DMG, shown when the DMG is mounted.

View File

@ -69,9 +69,9 @@ class PICTwindow(FrameWork.Window):
self.resid = resid self.resid = resid
picture = Qd.GetPicture(self.resid) picture = Qd.GetPicture(self.resid)
# Get rect for picture # Get rect for picture
print repr(picture.data[:16]) print(repr(picture.data[:16]))
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r print('pict:', t, l, b, r)
width = r-l width = r-l
height = b-t height = b-t
if width < 64: width = 64 if width < 64: width = 64
@ -79,7 +79,7 @@ class PICTwindow(FrameWork.Window):
if height < 64: height = 64 if height < 64: height = 64
elif height > 320: height = 320 elif height > 320: height = 320
bounds = (LEFT, TOP, LEFT+width, TOP+height) bounds = (LEFT, TOP, LEFT+width, TOP+height)
print 'bounds:', bounds print('bounds:', bounds)
self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
self.wid.SetWindowPic(picture) self.wid.SetWindowPic(picture)

View File

@ -68,9 +68,9 @@ class PICTwindow(FrameWork.Window):
self.resid = resid self.resid = resid
picture = Qd.GetPicture(self.resid) picture = Qd.GetPicture(self.resid)
# Get rect for picture # Get rect for picture
print repr(picture.data[:16]) print(repr(picture.data[:16]))
sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10]) sz, t, l, b, r = struct.unpack('hhhhh', picture.data[:10])
print 'pict:', t, l, b, r print('pict:', t, l, b, r)
width = r-l width = r-l
height = b-t height = b-t
if width < 64: width = 64 if width < 64: width = 64
@ -78,7 +78,7 @@ class PICTwindow(FrameWork.Window):
if height < 64: height = 64 if height < 64: height = 64
elif height > 320: height = 320 elif height > 320: height = 320
bounds = (LEFT, TOP, LEFT+width, TOP+height) bounds = (LEFT, TOP, LEFT+width, TOP+height)
print 'bounds:', bounds print('bounds:', bounds)
self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0) self.wid = Win.NewWindow(bounds, resname, 1, 0, -1, 1, 0)
self.wid.SetWindowPic(picture) self.wid.SetWindowPic(picture)
@ -115,7 +115,7 @@ class MyDialog(FrameWork.DialogWindow):
(what, message, when, where, modifiers) = event (what, message, when, where, modifiers) = event
Qd.SetPort(self.wid) Qd.SetPort(self.wid)
where = Qd.GlobalToLocal(where) where = Qd.GlobalToLocal(where)
print 'LISTHIT', where print('LISTHIT', where)
if self.list.LClick(where, modifiers): if self.list.LClick(where, modifiers):
self.do_show() self.do_show()

View File

@ -8,8 +8,8 @@ filespec = macfs.FSSpec('my disk image.img')
try: try:
objref = talker.create('my disk image', saving_as=filespec, leave_image_mounted=1) objref = talker.create('my disk image', saving_as=filespec, leave_image_mounted=1)
except Disk_Copy.Error as arg: except Disk_Copy.Error as arg:
print "ERROR: my disk image:", arg print("ERROR: my disk image:", arg)
else: else:
print 'objref=', objref print('objref=', objref)
print 'Type return to exit-' print('Type return to exit-')
sys.stdin.readline() sys.stdin.readline()

View File

@ -25,7 +25,7 @@ MAXHEIGHT=320
def main(): def main():
print 'hello world' print('hello world')
imgbrowse() imgbrowse()
class imgbrowse(FrameWork.Application): class imgbrowse(FrameWork.Application):
@ -84,10 +84,10 @@ class imgwindow(FrameWork.Window):
def do_update(self, *args): def do_update(self, *args):
pass pass
currect = self.fitrect() currect = self.fitrect()
print 'PICT:', self.pictrect print('PICT:', self.pictrect)
print 'WIND:', currect print('WIND:', currect)
print 'ARGS:', (self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, print('ARGS:', (self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect,
currect, QuickDraw.srcCopy, None) currect, QuickDraw.srcCopy, None))
self.info() self.info()
Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect, Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().GetPortBitMapForCopyBits(), self.pictrect,
currect, QuickDraw.srcCopy, None) currect, QuickDraw.srcCopy, None)

View File

@ -38,19 +38,19 @@ def dumppixmap(data):
cmpCount, cmpSize, \ cmpCount, cmpSize, \
planeBytes, pmTable, pmReserved \ planeBytes, pmTable, pmReserved \
= struct.unpack("lhhhhhhhlllhhhhlll", data) = struct.unpack("lhhhhhhhlllhhhhlll", data)
print 'Base: 0x%x'%baseAddr print('Base: 0x%x'%baseAddr)
print 'rowBytes: %d (0x%x)'%(rowBytes&0x3fff, rowBytes) print('rowBytes: %d (0x%x)'%(rowBytes&0x3fff, rowBytes))
print 'rect: %d, %d, %d, %d'%(t, l, b, r) print('rect: %d, %d, %d, %d'%(t, l, b, r))
print 'pmVersion: 0x%x'%pmVersion print('pmVersion: 0x%x'%pmVersion)
print 'packing: %d %d'%(packType, packSize) print('packing: %d %d'%(packType, packSize))
print 'resolution: %f x %f'%(float(hRes)/0x10000, float(vRes)/0x10000) print('resolution: %f x %f'%(float(hRes)/0x10000, float(vRes)/0x10000))
print 'pixeltype: %d, size %d'%(pixelType, pixelSize) print('pixeltype: %d, size %d'%(pixelType, pixelSize))
print 'components: %d, size %d'%(cmpCount, cmpSize) print('components: %d, size %d'%(cmpCount, cmpSize))
print 'planeBytes: %d (0x%x)'%(planeBytes, planeBytes) print('planeBytes: %d (0x%x)'%(planeBytes, planeBytes))
print 'pmTable: 0x%x'%pmTable print('pmTable: 0x%x'%pmTable)
print 'pmReserved: 0x%x'%pmReserved print('pmReserved: 0x%x'%pmReserved)
for i in range(0, len(data), 16): for i in range(0, len(data), 16):
for j in range(16): for j in range(16):
if i + j < len(data): if i + j < len(data):
print '%02.2x'%ord(data[i+j]), print('%02.2x'%ord(data[i+j]), end=' ')
print print()

View File

@ -18,7 +18,7 @@ import sys
# XXXX maxbounds = (40, 40, 1000, 1000) # XXXX maxbounds = (40, 40, 1000, 1000)
def main(): def main():
print 'hello world' # XXXX print('hello world') # XXXX
# skip the toolbox initializations, already done # skip the toolbox initializations, already done
# XXXX Should use gestalt here to check for quicktime version # XXXX Should use gestalt here to check for quicktime version
Qt.EnterMovies() Qt.EnterMovies()
@ -75,7 +75,7 @@ def main():
whichWindow = Win.WhichWindow(message) whichWindow = Win.WhichWindow(message)
if not whichWindow: if not whichWindow:
# Probably the console window. Print something, hope it helps. # Probably the console window. Print something, hope it helps.
print 'update' print('update')
else: else:
Qd.SetPort(whichWindow) Qd.SetPort(whichWindow)
whichWindow.BeginUpdate() whichWindow.BeginUpdate()

View File

@ -34,7 +34,7 @@ def copyres(src, dst):
id, type, name = res.GetResInfo() id, type, name = res.GetResInfo()
size = res.SizeResource() size = res.SizeResource()
attrs = res.GetResAttrs() attrs = res.GetResAttrs()
print id, type, name, size, hex(attrs) print(id, type, name, size, hex(attrs))
res.DetachResource() res.DetachResource()
UseResFile(output) UseResFile(output)
try: try:
@ -42,15 +42,15 @@ def copyres(src, dst):
except (RuntimeError, Res.Error) as msg: except (RuntimeError, Res.Error) as msg:
res2 = None res2 = None
if res2: if res2:
print "Duplicate type+id, not copied" print("Duplicate type+id, not copied")
print (res2.size, res2.data) print (res2.size, res2.data)
print res2.GetResInfo() print(res2.GetResInfo())
if res2.HomeResFile() == output: if res2.HomeResFile() == output:
'OK' 'OK'
elif res2.HomeResFile() == input: elif res2.HomeResFile() == input:
'BAD!' 'BAD!'
else: else:
print 'Home:', res2.HomeResFile() print('Home:', res2.HomeResFile())
else: else:
res.AddResource(type, id, name) res.AddResource(type, id, name)
#res.SetResAttrs(attrs) #res.SetResAttrs(attrs)

View File

@ -7,7 +7,7 @@ def list1resources():
ntypes = Res.Count1Types() ntypes = Res.Count1Types()
for itype in range(1, 1+ntypes): for itype in range(1, 1+ntypes):
type = Res.Get1IndType(itype) type = Res.Get1IndType(itype)
print "Type:", repr(type) print("Type:", repr(type))
nresources = Res.Count1Resources(type) nresources = Res.Count1Resources(type)
for i in range(1, 1 + nresources): for i in range(1, 1 + nresources):
Res.SetResLoad(0) Res.SetResLoad(0)
@ -19,7 +19,7 @@ def listresources():
ntypes = Res.CountTypes() ntypes = Res.CountTypes()
for itype in range(1, 1+ntypes): for itype in range(1, 1+ntypes):
type = Res.GetIndType(itype) type = Res.GetIndType(itype)
print "Type:", repr(type) print("Type:", repr(type))
nresources = Res.CountResources(type) nresources = Res.CountResources(type)
for i in range(1, 1 + nresources): for i in range(1, 1 + nresources):
Res.SetResLoad(0) Res.SetResLoad(0)
@ -28,7 +28,7 @@ def listresources():
info(res) info(res)
def info(res): def info(res):
print res.GetResInfo(), res.SizeResource(), decodeattrs(res.GetResAttrs()) print(res.GetResInfo(), res.SizeResource(), decodeattrs(res.GetResAttrs()))
attrnames = { attrnames = {
resChanged: 'Changed', resChanged: 'Changed',
@ -51,9 +51,9 @@ def decodeattrs(attrs):
return names return names
def test(): def test():
print "=== Local resourcess ===" print("=== Local resourcess ===")
list1resources() list1resources()
print "=== All resources ===" print("=== All resources ===")
listresources() listresources()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -5,16 +5,16 @@ import aifc, audioop
fn = 'f:just samples:2ndbeat.aif' fn = 'f:just samples:2ndbeat.aif'
af = aifc.open(fn, 'r') af = aifc.open(fn, 'r')
print af.getparams() print(af.getparams())
print 'nframes =', af.getnframes() print('nframes =', af.getnframes())
print 'nchannels =', af.getnchannels() print('nchannels =', af.getnchannels())
print 'framerate =', af.getframerate() print('framerate =', af.getframerate())
nframes = min(af.getnframes(), 100000) nframes = min(af.getnframes(), 100000)
frames = af.readframes(nframes) frames = af.readframes(nframes)
print 'len(frames) =', len(frames) print('len(frames) =', len(frames))
print repr(frames[:100]) print(repr(frames[:100]))
frames = audioop.add(frames, '\x80'*len(frames), 1) frames = audioop.add(frames, '\x80'*len(frames), 1)
print repr(frames[:100]) print(repr(frames[:100]))
import struct import struct
@ -27,7 +27,7 @@ header1 = struct.pack('llhhllbbl',
0xFF, 0xFF,
60, 60,
nframes) nframes)
print repr(header1) print(repr(header1))
header2 = struct.pack('llhlll', 0, 0, 0, 0, 0, 0) header2 = struct.pack('llhlll', 0, 0, 0, 0, 0, 0)
header3 = struct.pack('hhlll', header3 = struct.pack('hhlll',
af.getsampwidth()*8, af.getsampwidth()*8,
@ -35,7 +35,7 @@ header3 = struct.pack('hhlll',
0, 0,
0, 0,
0) 0)
print repr(header3) print(repr(header3))
header = header1 + header2 + header3 header = header1 + header2 + header3
buffer = header + frames buffer = header + frames

View File

@ -50,7 +50,7 @@ class TEWindow(ScrolledWindow):
height = self.ted.nLines * self.ted.lineHeight height = self.ted.nLines * self.ted.lineHeight
vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2]) vx = self.scalebarvalue(dr[0], dr[2]-dr[0], vr[0], vr[2])
vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3]) vy = self.scalebarvalue(dr[1], dr[1]+height, vr[1], vr[3])
print dr, vr, height, vx, vy print(dr, vr, height, vx, vy)
return None, vy return None, vy
def scrollbar_callback(self, which, what, value): def scrollbar_callback(self, which, what, value):
@ -72,12 +72,12 @@ class TEWindow(ScrolledWindow):
if delta >= 0: if delta >= 0:
delta = -self.ted.lineHeight delta = -self.ted.lineHeight
self.ted.TEPinScroll(0, delta) self.ted.TEPinScroll(0, delta)
print 'SCROLL Y', delta print('SCROLL Y', delta)
else: else:
pass # No horizontal scrolling pass # No horizontal scrolling
def do_activate(self, onoff, evt): def do_activate(self, onoff, evt):
print "ACTIVATE", onoff print("ACTIVATE", onoff)
ScrolledWindow.do_activate(self, onoff, evt) ScrolledWindow.do_activate(self, onoff, evt)
if onoff: if onoff:
self.ted.TEActivate() self.ted.TEActivate()
@ -121,7 +121,7 @@ class TEWindow(ScrolledWindow):
if not self.path: if not self.path:
self.menu_save_as() self.menu_save_as()
return # Will call us recursively return # Will call us recursively
print 'Saving to ', self.path print('Saving to ', self.path)
dhandle = self.ted.TEGetText() dhandle = self.ted.TEGetText()
data = dhandle.data data = dhandle.data
fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line fp = open(self.path, 'wb') # NOTE: wb, because data has CR for end-of-line

View File

@ -25,23 +25,23 @@ def copycleandir(src, dst):
assert cursrc.startswith(src) assert cursrc.startswith(src)
curdst = dst + cursrc[len(src):] curdst = dst + cursrc[len(src):]
if verbose: if verbose:
print "mkdir", curdst print("mkdir", curdst)
if not debug: if not debug:
if not os.path.exists(curdst): if not os.path.exists(curdst):
os.makedirs(curdst) os.makedirs(curdst)
for fn in files: for fn in files:
if isclean(fn): if isclean(fn):
if verbose: if verbose:
print "copy", os.path.join(cursrc, fn), os.path.join(curdst, fn) print("copy", os.path.join(cursrc, fn), os.path.join(curdst, fn))
if not debug: if not debug:
shutil.copy2(os.path.join(cursrc, fn), os.path.join(curdst, fn)) shutil.copy2(os.path.join(cursrc, fn), os.path.join(curdst, fn))
else: else:
if verbose: if verbose:
print "skipfile", os.path.join(cursrc, fn) print("skipfile", os.path.join(cursrc, fn))
for i in range(len(dirs)-1, -1, -1): for i in range(len(dirs)-1, -1, -1):
if not isclean(dirs[i]): if not isclean(dirs[i]):
if verbose: if verbose:
print "skipdir", os.path.join(cursrc, dirs[i]) print("skipdir", os.path.join(cursrc, dirs[i]))
del dirs[i] del dirs[i]
def main(): def main():

View File

@ -13,18 +13,18 @@ sys.path.append(BGENDIR)
from scantools import Scanner from scantools import Scanner
def main(): def main():
print "=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ===" print("=== Scanning AEDataModel.h, AppleEvents.h, AERegistry.h, AEObjects.h ===")
input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"] input = ["AEDataModel.h", "AEInteraction.h", "AppleEvents.h", "AERegistry.h", "AEObjects.h"]
output = "aegen.py" output = "aegen.py"
defsoutput = TOOLBOXDIR + "AppleEvents.py" defsoutput = TOOLBOXDIR + "AppleEvents.py"
scanner = AppleEventsScanner(input, output, defsoutput) scanner = AppleEventsScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done Scanning and Generating, now doing 'import aesupport' ===" print("=== Done Scanning and Generating, now doing 'import aesupport' ===")
import aesupport import aesupport
print "=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===" print("=== Done 'import aesupport'. It's up to you to compile AEmodule.c ===")
class AppleEventsScanner(Scanner): class AppleEventsScanner(Scanner):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -12,18 +12,18 @@ sys.path.append(BGENDIR)
from scantools import Scanner, Scanner_OSX from scantools import Scanner, Scanner_OSX
def main(): def main():
print "---Scanning CarbonEvents.h---" print("---Scanning CarbonEvents.h---")
input = ["CarbonEvents.h"] input = ["CarbonEvents.h"]
output = "CarbonEventsgen.py" output = "CarbonEventsgen.py"
defsoutput = TOOLBOXDIR + "CarbonEvents.py" defsoutput = TOOLBOXDIR + "CarbonEvents.py"
scanner = CarbonEvents_Scanner(input, output, defsoutput) scanner = CarbonEvents_Scanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "--done scanning, importing--" print("--done scanning, importing--")
import CarbonEvtsupport import CarbonEvtsupport
print "done" print("done")
RefObjectTypes = ["EventRef", RefObjectTypes = ["EventRef",
"EventQueueRef", "EventQueueRef",

View File

@ -44,11 +44,11 @@ def main():
scanner.scan() scanner.scan()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -22,11 +22,11 @@ def main():
scanner.scan() scanner.scan()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -16,11 +16,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -14,11 +14,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import ctlsupport' ===" print("=== Done scanning and generating, now doing 'import ctlsupport' ===")
import ctlsupport import ctlsupport
print "=== Done. It's up to you to compile Ctlmodule.c ===" print("=== Done. It's up to you to compile Ctlmodule.c ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -18,11 +18,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -25,11 +25,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import dragsupport' ===" print("=== Done scanning and generating, now doing 'import dragsupport' ===")
import dragsupport import dragsupport
print "=== Done. It's up to you to compile Dragmodule.c ===" print("=== Done. It's up to you to compile Dragmodule.c ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -17,11 +17,11 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -16,11 +16,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -18,11 +18,11 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -10,18 +10,18 @@ sys.path.append(BGENDIR)
from scantools import Scanner_OSX from scantools import Scanner_OSX
def main(): def main():
print "---Scanning IBCarbonRuntime.h---" print("---Scanning IBCarbonRuntime.h---")
input = ["IBCarbonRuntime.h"] input = ["IBCarbonRuntime.h"]
output = "IBCarbongen.py" output = "IBCarbongen.py"
defsoutput = TOOLBOXDIR + "IBCarbonRuntime.py" defsoutput = TOOLBOXDIR + "IBCarbonRuntime.py"
scanner = IBCarbon_Scanner(input, output, defsoutput) scanner = IBCarbon_Scanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "--done scanning, importing--" print("--done scanning, importing--")
import IBCarbonsupport import IBCarbonsupport
print "done" print("done")
class IBCarbon_Scanner(Scanner_OSX): class IBCarbon_Scanner(Scanner_OSX):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -18,11 +18,11 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -13,11 +13,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import menusupport' ===" print("=== Done scanning and generating, now doing 'import menusupport' ===")
import menusupport import menusupport
print "=== Done. It's up to you to compile Menumodule.c ===" print("=== Done. It's up to you to compile Menumodule.c ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -19,11 +19,11 @@ def main():
scanner.scan() scanner.scan()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner_OSX): class MyScanner(Scanner_OSX):

View File

@ -17,11 +17,11 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -28,7 +28,7 @@ def main():
except IOError: except IOError:
pass pass
if have_extra: if have_extra:
print "=== Copying QuickDrawText stuff into main files... ===" print("=== Copying QuickDrawText stuff into main files... ===")
ifp = open("@qdgentext.py") ifp = open("@qdgentext.py")
ofp = open("qdgen.py", "a") ofp = open("qdgen.py", "a")
ofp.write(ifp.read()) ofp.write(ifp.read())
@ -40,11 +40,11 @@ def main():
ifp.close() ifp.close()
ofp.close() ofp.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
import qdsupport import qdsupport
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -13,11 +13,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
import qdoffssupport import qdoffssupport
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -34,11 +34,11 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
scanner.gentypetest(SHORT+"typetest.py") scanner.gentypetest(SHORT+"typetest.py")
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -19,11 +19,11 @@ def main():
scanner = ResourcesScanner(input, output, defsoutput) scanner = ResourcesScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import ressupport' ===" print("=== Done scanning and generating, now doing 'import ressupport' ===")
import ressupport import ressupport
print "=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===" print("=== Done 'import ressupport'. It's up to you to compile Resmodule.c ===")
class ResourcesScanner(Scanner): class ResourcesScanner(Scanner):

View File

@ -21,9 +21,9 @@ def main():
scanner.close() scanner.close()
## print "=== Testing definitions output code ===" ## print "=== Testing definitions output code ==="
## exec(open(defsoutput).read(), {}, {}) ## exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -16,11 +16,11 @@ def main():
scanner = SoundScanner(input, output, defsoutput) scanner = SoundScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now doing 'import sndsupport' ===" print("=== Done scanning and generating, now doing 'import sndsupport' ===")
import sndsupport import sndsupport
print "=== Done. It's up to you to compile Sndmodule.c ===" print("=== Done. It's up to you to compile Sndmodule.c ===")
class SoundScanner(Scanner): class SoundScanner(Scanner):

View File

@ -17,11 +17,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
exec "import " + SHORT + "support" exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -13,11 +13,11 @@ def main():
scanner = MyScanner(input, output, defsoutput) scanner = MyScanner(input, output, defsoutput)
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "=== Testing definitions output code ===" print("=== Testing definitions output code ===")
exec(open(defsoutput).read(), {}, {}) exec(open(defsoutput).read(), {}, {})
print "=== Done scanning and generating, now importing the generated code... ===" print("=== Done scanning and generating, now importing the generated code... ===")
import winsupport import winsupport
print "=== Done. It's up to you to compile it now! ===" print("=== Done. It's up to you to compile it now! ===")
class MyScanner(Scanner): class MyScanner(Scanner):

View File

@ -100,7 +100,7 @@ class DocBuild(build):
if os.path.isdir(origPath): if os.path.isdir(origPath):
self.mkpath(outPath) self.mkpath(outPath)
elif ext == '.html': elif ext == '.html':
if self.verbose: print 'hacking %s to %s' % (origPath,outPath) if self.verbose: print('hacking %s to %s' % (origPath,outPath))
hackedFile = file(outPath, 'w') hackedFile = file(outPath, 'w')
origFile = file(origPath,'r') origFile = file(origPath,'r')
hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read())) hackedFile.write(self.r.sub('<dl><dt><dd>', origFile.read()))
@ -118,7 +118,7 @@ class DocBuild(build):
def makeHelpIndex(self): def makeHelpIndex(self):
app = '/Developer/Applications/Apple Help Indexing Tool.app' app = '/Developer/Applications/Apple Help Indexing Tool.app'
self.spawn('open', '-a', app , self.build_dest) self.spawn('open', '-a', app , self.build_dest)
print "Please wait until Apple Help Indexing Tool finishes before installing" print("Please wait until Apple Help Indexing Tool finishes before installing")
def makeHelpIndex(self): def makeHelpIndex(self):
app = HelpIndexingTool.HelpIndexingTool(start=1) app = HelpIndexingTool.HelpIndexingTool(start=1)
@ -180,18 +180,18 @@ class AHVDocInstall(Command):
self.build_dest = build_cmd.build_dest self.build_dest = build_cmd.build_dest
if self.install_doc == None: if self.install_doc == None:
self.install_doc = os.path.join(self.prefix, DESTDIR) self.install_doc = os.path.join(self.prefix, DESTDIR)
print 'INSTALL', self.build_dest, '->', self.install_doc print('INSTALL', self.build_dest, '->', self.install_doc)
def run(self): def run(self):
self.finalize_options() self.finalize_options()
self.ensure_finalized() self.ensure_finalized()
print "Running Installer" print("Running Installer")
instloc = self.install_doc instloc = self.install_doc
if self.root: if self.root:
instloc = change_root(self.root, instloc) instloc = change_root(self.root, instloc)
self.mkpath(instloc) self.mkpath(instloc)
copy_tree(self.build_dest, instloc) copy_tree(self.build_dest, instloc)
print "Installation complete" print("Installation complete")
def mungeVersion(infile, outfile): def mungeVersion(infile, outfile):
i = file(infile,'r') i = file(infile,'r')

View File

@ -57,23 +57,23 @@ def fix(makefile, do_apply):
continue continue
i = findline(lines, old) i = findline(lines, old)
if i < 0: if i < 0:
print 'fixapplepython23: Python installation not fixed (appears broken)' print('fixapplepython23: Python installation not fixed (appears broken)')
print 'fixapplepython23: missing line:', old print('fixapplepython23: missing line:', old)
return 2 return 2
lines[i] = new lines[i] = new
fixed = True fixed = True
if fixed: if fixed:
if do_apply: if do_apply:
print 'fixapplepython23: Fix to Apple-installed Python 2.3 applied' print('fixapplepython23: Fix to Apple-installed Python 2.3 applied')
os.rename(makefile, makefile + '~') os.rename(makefile, makefile + '~')
open(makefile, 'w').writelines(lines) open(makefile, 'w').writelines(lines)
return 0 return 0
else: else:
print 'fixapplepython23: Fix to Apple-installed Python 2.3 should be applied' print('fixapplepython23: Fix to Apple-installed Python 2.3 should be applied')
return 1 return 1
else: else:
print 'fixapplepython23: No fix needed, appears to have been applied before' print('fixapplepython23: No fix needed, appears to have been applied before')
return 0 return 0
def makescript(filename, compiler): def makescript(filename, compiler):
@ -85,7 +85,7 @@ def makescript(filename, compiler):
fp.write(SCRIPT % compiler) fp.write(SCRIPT % compiler)
fp.close() fp.close()
os.chmod(filename, 0755) os.chmod(filename, 0755)
print 'fixapplepython23: Created', filename print('fixapplepython23: Created', filename)
def main(): def main():
# Check for -n option # Check for -n option
@ -96,24 +96,24 @@ def main():
# First check OS version # First check OS version
if sys.byteorder == 'little': if sys.byteorder == 'little':
# All intel macs are fine # All intel macs are fine
print "fixapplypython23: no fix is needed on MacOSX on Intel" print("fixapplypython23: no fix is needed on MacOSX on Intel")
sys.exit(0) sys.exit(0)
if gestalt.gestalt('sysv') < 0x1030: if gestalt.gestalt('sysv') < 0x1030:
print 'fixapplepython23: no fix needed on MacOSX < 10.3' print('fixapplepython23: no fix needed on MacOSX < 10.3')
sys.exit(0) sys.exit(0)
if gestalt.gestalt('sysv') >= 0x1040: if gestalt.gestalt('sysv') >= 0x1040:
print 'fixapplepython23: no fix needed on MacOSX >= 10.4' print('fixapplepython23: no fix needed on MacOSX >= 10.4')
sys.exit(0) sys.exit(0)
# Test that a framework Python is indeed installed # Test that a framework Python is indeed installed
if not os.path.exists(MAKEFILE): if not os.path.exists(MAKEFILE):
print 'fixapplepython23: Python framework does not appear to be installed (?), nothing fixed' print('fixapplepython23: Python framework does not appear to be installed (?), nothing fixed')
sys.exit(0) sys.exit(0)
# Check that we can actually write the file # Check that we can actually write the file
if do_apply and not os.access(MAKEFILE, os.W_OK): if do_apply and not os.access(MAKEFILE, os.W_OK):
print 'fixapplepython23: No write permission, please run with "sudo"' print('fixapplepython23: No write permission, please run with "sudo"')
sys.exit(2) sys.exit(2)
# Create the shell scripts # Create the shell scripts
if do_apply: if do_apply:

View File

@ -116,18 +116,18 @@ def buildapplet():
progress=verbose, destroot=destroot) progress=verbose, destroot=destroot)
def usage(): def usage():
print "BuildApplet creates an application from a Python source file" print("BuildApplet creates an application from a Python source file")
print "Usage:" print("Usage:")
print " BuildApplet interactive, single file, no options" print(" BuildApplet interactive, single file, no options")
print " BuildApplet src1.py src2.py ... non-interactive multiple file" print(" BuildApplet src1.py src2.py ... non-interactive multiple file")
print " BuildApplet [options] src.py non-interactive single file" print(" BuildApplet [options] src.py non-interactive single file")
print "Options:" print("Options:")
print " --output o Output file; default based on source filename, short -o" print(" --output o Output file; default based on source filename, short -o")
print " --resource r Resource file; default based on source filename, short -r" print(" --resource r Resource file; default based on source filename, short -r")
print " --noargv Build applet without drag-and-drop sys.argv emulation, short -n, OSX only" print(" --noargv Build applet without drag-and-drop sys.argv emulation, short -n, OSX only")
print " --extra src[:dst] Extra file to put in .app bundle, short -e, OSX only" print(" --extra src[:dst] Extra file to put in .app bundle, short -e, OSX only")
print " --verbose Verbose, short -v" print(" --verbose Verbose, short -v")
print " --help This message, short -?" print(" --help This message, short -?")
sys.exit(1) sys.exit(1)
class Verbose: class Verbose:

View File

@ -6,7 +6,7 @@ import string
def bgenone(dirname, shortname): def bgenone(dirname, shortname):
os.chdir(dirname) os.chdir(dirname)
print '%s:'%shortname print('%s:'%shortname)
# Sigh, we don't want to lose CVS history, so two # Sigh, we don't want to lose CVS history, so two
# modules have funny names: # modules have funny names:
if shortname == 'carbonevt': if shortname == 'carbonevt':
@ -18,12 +18,12 @@ def bgenone(dirname, shortname):
try: try:
m = __import__(modulename) m = __import__(modulename)
except: except:
print "Error:", shortname, sys.exc_info()[1] print("Error:", shortname, sys.exc_info()[1])
return 0 return 0
try: try:
m.main() m.main()
except: except:
print "Error:", shortname, sys.exc_info()[1] print("Error:", shortname, sys.exc_info()[1])
return 0 return 0
return 1 return 1
@ -45,9 +45,9 @@ def main():
success.append(name) success.append(name)
else: else:
failure.append(name) failure.append(name)
print 'Done:', string.join(success, ' ') print('Done:', string.join(success, ' '))
if failure: if failure:
print 'Failed:', string.join(failure, ' ') print('Failed:', string.join(failure, ' '))
return 0 return 0
return 1 return 1

View File

@ -417,18 +417,18 @@ def printUsage():
"Print usage message." "Print usage message."
format = "Usage: %s <opts1> [<opts2>] <root> [<resources>]" format = "Usage: %s <opts1> [<opts2>] <root> [<resources>]"
print format % basename(sys.argv[0]) print(format % basename(sys.argv[0]))
print print()
print " with arguments:" print(" with arguments:")
print " (mandatory) root: the package root folder" print(" (mandatory) root: the package root folder")
print " (optional) resources: the package resources folder" print(" (optional) resources: the package resources folder")
print print()
print " and options:" print(" and options:")
print " (mandatory) opts1:" print(" (mandatory) opts1:")
mandatoryKeys = string.split("Title Version Description", " ") mandatoryKeys = string.split("Title Version Description", " ")
for k in mandatoryKeys: for k in mandatoryKeys:
print " --%s" % k print(" --%s" % k)
print " (optional) opts2: (with default values)" print(" (optional) opts2: (with default values)")
pmDefaults = PackageMaker.packageInfoDefaults pmDefaults = PackageMaker.packageInfoDefaults
optionalKeys = pmDefaults.keys() optionalKeys = pmDefaults.keys()
@ -439,7 +439,7 @@ def printUsage():
for k in optionalKeys: for k in optionalKeys:
format = " --%%s:%s %%s" format = " --%%s:%s %%s"
format = format % (" " * (maxKeyLen-len(k))) format = format % (" " * (maxKeyLen-len(k)))
print format % (k, repr(pmDefaults[k])) print(format % (k, repr(pmDefaults[k])))
def main(): def main():
@ -452,7 +452,7 @@ def main():
try: try:
opts, args = getopt.getopt(sys.argv[1:], shortOpts, longOpts) opts, args = getopt.getopt(sys.argv[1:], shortOpts, longOpts)
except getopt.GetoptError as details: except getopt.GetoptError as details:
print details print(details)
printUsage() printUsage()
return return
@ -462,11 +462,11 @@ def main():
ok = optsDict.keys() ok = optsDict.keys()
if not (1 <= len(args) <= 2): if not (1 <= len(args) <= 2):
print "No argument given!" print("No argument given!")
elif not ("Title" in ok and \ elif not ("Title" in ok and \
"Version" in ok and \ "Version" in ok and \
"Description" in ok): "Description" in ok):
print "Missing mandatory option!" print("Missing mandatory option!")
else: else:
buildPackage(*args, **optsDict) buildPackage(*args, **optsDict)
return return

View File

@ -68,9 +68,9 @@ def parse_errno_h(fp, dict):
if not dict.has_key(number): if not dict.has_key(number):
dict[number] = desc, name dict[number] = desc, name
else: else:
print 'DUPLICATE', number print('DUPLICATE', number)
print '\t', dict[number] print('\t', dict[number])
print '\t', (desc, name) print('\t', (desc, name))
def parse_errors_h(fp, dict): def parse_errors_h(fp, dict):
errno_prog = re.compile(ERRORS_PROG) errno_prog = re.compile(ERRORS_PROG)
@ -95,11 +95,11 @@ def parse_errors_h(fp, dict):
if not dict.has_key(number): if not dict.has_key(number):
dict[number] = desc, name dict[number] = desc, name
else: else:
print 'DUPLICATE', number print('DUPLICATE', number)
print '\t', dict[number] print('\t', dict[number])
print '\t', (desc, name) print('\t', (desc, name))
if len(desc) > len(dict[number][0]): if len(desc) > len(dict[number][0]):
print 'Pick second one' print('Pick second one')
dict[number] = desc, name dict[number] = desc, name
def main(): def main():

View File

@ -16,7 +16,7 @@ def main():
sys.exit(0) sys.exit(0)
zappyc(dir) zappyc(dir)
else: else:
print 'Usage: zappyc dir ...' print('Usage: zappyc dir ...')
sys.exit(1) sys.exit(1)
for dir in sys.argv[1:]: for dir in sys.argv[1:]:
zappyc(dir) zappyc(dir)
@ -28,7 +28,7 @@ def walker(dummy, top, names):
for name in names: for name in names:
if name[-4:] in ('.pyc', '.pyo'): if name[-4:] in ('.pyc', '.pyo'):
path = os.path.join(top, name) path = os.path.join(top, name)
print 'Zapping', path print('Zapping', path)
if doit: if doit:
os.unlink(path) os.unlink(path)

View File

@ -62,16 +62,16 @@ def test_recurse():
def check_limit(n, test_func_name): def check_limit(n, test_func_name):
sys.setrecursionlimit(n) sys.setrecursionlimit(n)
if test_func_name.startswith("test_"): if test_func_name.startswith("test_"):
print test_func_name[5:] print(test_func_name[5:])
else: else:
print test_func_name print(test_func_name)
test_func = globals()[test_func_name] test_func = globals()[test_func_name]
try: try:
test_func() test_func()
except RuntimeError: except RuntimeError:
pass pass
else: else:
print "Yikes!" print("Yikes!")
limit = 1000 limit = 1000
while 1: while 1:
@ -81,5 +81,5 @@ while 1:
check_limit(limit, "test_init") check_limit(limit, "test_init")
check_limit(limit, "test_getattr") check_limit(limit, "test_getattr")
check_limit(limit, "test_getitem") check_limit(limit, "test_getitem")
print "Limit of %d is fine" % limit print("Limit of %d is fine" % limit)
limit = limit + 100 limit = limit + 100

View File

@ -22,14 +22,14 @@ levelnum = {'alpha': 0xA,
}[level] }[level]
string = sys.version.split()[0] # like '2.3a0' string = sys.version.split()[0] # like '2.3a0'
print " * For %s," % string print(" * For %s," % string)
print " * PY_MICRO_VERSION = %d" % micro print(" * PY_MICRO_VERSION = %d" % micro)
print " * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)) print(" * PY_RELEASE_LEVEL = %r = %s" % (level, hex(levelnum)))
print " * PY_RELEASE_SERIAL = %d" % serial print(" * PY_RELEASE_SERIAL = %d" % serial)
print " *" print(" *")
field3 = micro * 1000 + levelnum * 10 + serial field3 = micro * 1000 + levelnum * 10 + serial
print " * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3) print(" * and %d*1000 + %d*10 + %d = %d" % (micro, levelnum, serial, field3))
print " */" print(" */")
print "#define FIELD3", field3 print("#define FIELD3", field3)