diff --git a/ArchiveViewer.py b/ArchiveViewer.py index e2cb576..0b737ee 100755 --- a/ArchiveViewer.py +++ b/ArchiveViewer.py @@ -147,7 +147,7 @@ class ZlibArchive(archive.ZlibArchive): Check to see if the file object self.lib actually has a file we understand. """ - self.lib.seek(self.start) #default - magic is at start of file + self.lib.seek(self.start) #default - magic is at start of file if self.lib.read(len(self.MAGIC)) != self.MAGIC: raise RuntimeError, "%s is not a valid %s archive file" \ % (self.path, self.__class__.__name__) @@ -157,4 +157,3 @@ class ZlibArchive(archive.ZlibArchive): if __name__ == '__main__': main() - diff --git a/Build.py b/Build.py index 56e8a3b..3f5ab4b 100755 --- a/Build.py +++ b/Build.py @@ -200,7 +200,7 @@ class Analysis(Target): paths[i] = absnormpath(paths[i]) ################################################### # Scan inputs and prepare: - dirs = {} # input directories + dirs = {} # input directories pynms = [] # python filenames with no extension for script in self.inputs: if not os.path.exists(script): diff --git a/GrabVersion.py b/GrabVersion.py index 0d59732..2417123 100644 --- a/GrabVersion.py +++ b/GrabVersion.py @@ -28,4 +28,3 @@ if len(sys.argv) < 2: else: vs = versionInfo.decode(sys.argv[1]) print vs - diff --git a/archive.py b/archive.py index 0e7b7fd..1208587 100644 --- a/archive.py +++ b/archive.py @@ -106,7 +106,7 @@ class Archive: Check to see if the file object self.lib actually has a file we understand. """ - self.lib.seek(self.start) #default - magic is at start of file + self.lib.seek(self.start) #default - magic is at start of file if self.lib.read(len(self.MAGIC)) != self.MAGIC: raise ArchiveReadError, "%s is not a valid %s archive file" \ % (self.path, self.__class__.__name__) @@ -255,7 +255,7 @@ class Archive: assert ext in ('.pyc', '.pyo') self.toc[nm] = (ispkg, self.lib.tell()) f = open(entry[1], 'rb') - f.seek(8) #skip magic and timestamp + f.seek(8) #skip magic and timestamp self.lib.write(f.read()) def save_toc(self, tocpos): @@ -345,7 +345,7 @@ class ZlibArchive(Archive): except (IOError, OSError): try: f = open(pth, 'rb') - f.seek(8) #skip magic and timestamp + f.seek(8) #skip magic and timestamp bytecode = f.read() marshal.loads(bytecode).co_filename # to make sure it's valid obj = zlib.compress(bytecode, self.LEVEL) diff --git a/bindepend.py b/bindepend.py index 8a36c33..2788f54 100755 --- a/bindepend.py +++ b/bindepend.py @@ -87,29 +87,29 @@ excludes = {'KERNEL32.DLL':1, excludesRe = re.compile('|'.join(excludes.keys()), re.I) def getfullnameof(mod, xtrapath = None): - """Return the full path name of MOD. + """Return the full path name of MOD. - MOD is the basename of a dll or pyd. - XTRAPATH is a path or list of paths to search first. - Return the full path name of MOD. - Will search the full Windows search path, as well as sys.path""" - # Search sys.path first! - epath = sys.path + getWindowsPath() - if xtrapath is not None: - if type(xtrapath) == type(''): - epath.insert(0, xtrapath) - else: - epath = xtrapath + epath - for p in epath: - npth = os.path.join(p, mod) - if os.path.exists(npth): - return npth - # second try: lower case filename + MOD is the basename of a dll or pyd. + XTRAPATH is a path or list of paths to search first. + Return the full path name of MOD. + Will search the full Windows search path, as well as sys.path""" + # Search sys.path first! + epath = sys.path + getWindowsPath() + if xtrapath is not None: + if type(xtrapath) == type(''): + epath.insert(0, xtrapath) + else: + epath = xtrapath + epath for p in epath: - npth = os.path.join(p, string.lower(mod)) + npth = os.path.join(p, mod) if os.path.exists(npth): return npth - return '' + # second try: lower case filename + for p in epath: + npth = os.path.join(p, string.lower(mod)) + if os.path.exists(npth): + return npth + return '' def _getImports_dumpbin(pth): """Find the binary dependencies of PTH. @@ -137,58 +137,58 @@ def _getImports_pe_x(pth): import struct rslt = [] try: - f = open(pth, 'rb').read() - pehdrd = struct.unpack('l', f[60:64])[0] #after the MSDOS loader is the offset of the peheader - magic = struct.unpack('l', f[pehdrd:pehdrd+4])[0] # pehdr starts with magic 'PE\000\000' (or 17744) - # then 20 bytes of COFF header - numsecs = struct.unpack('h', f[pehdrd+6:pehdrd+8])[0] # whence we get number of sections - opthdrmagic = struct.unpack('h', f[pehdrd+24:pehdrd+26])[0] - if opthdrmagic == 0x10b: # PE32 format - numdictoffset = 116 - importoffset = 128 - elif opthdrmagic == 0x20b: # PE32+ format - numdictoffset = 132 - importoffset = 148 - else: - print "E: bindepend cannot analyze %s - unknown header format! %x" % (pth, opthdrmagic) - return rslt - numdirs = struct.unpack('l', f[pehdrd+numdictoffset:pehdrd+numdictoffset+4])[0] - idata = '' - if magic == 17744: - importsec, sz = struct.unpack('2l', f[pehdrd+importoffset:pehdrd+importoffset+8]) - if sz == 0: - return rslt - secttbl = pehdrd + numdictoffset + 4 + 8*numdirs - secttblfmt = '8s7l2h' - seclist = [] - for i in range(numsecs): - seclist.append(struct.unpack(secttblfmt, f[secttbl+i*40:secttbl+(i+1)*40])) - #nm, vsz, va, rsz, praw, preloc, plnnums, qrelocs, qlnnums, flags \ - # = seclist[-1] - for i in range(len(seclist)-1): - if seclist[i][2] <= importsec < seclist[i+1][2]: - break - vbase = seclist[i][2] - raw = seclist[i][4] - idatastart = raw + importsec - vbase - idata = f[idatastart:idatastart+seclist[i][1]] - i = 0 - while 1: - chunk = idata[i*20:(i+1)*20] - if len(chunk) != 20: - print "E: premature end of import table (chunk is %d, not 20)" % len(chunk) - break - vsa = struct.unpack('5l', chunk)[3] - if vsa == 0: - break - sa = raw + vsa - vbase - end = string.find(f, '\000', sa) - nm = f[sa:end] - if nm: - rslt.append(nm) - i = i + 1 - else: - print "E: bindepend cannot analyze %s - file is not in PE format!" % pth + f = open(pth, 'rb').read() + pehdrd = struct.unpack('l', f[60:64])[0] #after the MSDOS loader is the offset of the peheader + magic = struct.unpack('l', f[pehdrd:pehdrd+4])[0] # pehdr starts with magic 'PE\000\000' (or 17744) + # then 20 bytes of COFF header + numsecs = struct.unpack('h', f[pehdrd+6:pehdrd+8])[0] # whence we get number of sections + opthdrmagic = struct.unpack('h', f[pehdrd+24:pehdrd+26])[0] + if opthdrmagic == 0x10b: # PE32 format + numdictoffset = 116 + importoffset = 128 + elif opthdrmagic == 0x20b: # PE32+ format + numdictoffset = 132 + importoffset = 148 + else: + print "E: bindepend cannot analyze %s - unknown header format! %x" % (pth, opthdrmagic) + return rslt + numdirs = struct.unpack('l', f[pehdrd+numdictoffset:pehdrd+numdictoffset+4])[0] + idata = '' + if magic == 17744: + importsec, sz = struct.unpack('2l', f[pehdrd+importoffset:pehdrd+importoffset+8]) + if sz == 0: + return rslt + secttbl = pehdrd + numdictoffset + 4 + 8*numdirs + secttblfmt = '8s7l2h' + seclist = [] + for i in range(numsecs): + seclist.append(struct.unpack(secttblfmt, f[secttbl+i*40:secttbl+(i+1)*40])) + #nm, vsz, va, rsz, praw, preloc, plnnums, qrelocs, qlnnums, flags \ + # = seclist[-1] + for i in range(len(seclist)-1): + if seclist[i][2] <= importsec < seclist[i+1][2]: + break + vbase = seclist[i][2] + raw = seclist[i][4] + idatastart = raw + importsec - vbase + idata = f[idatastart:idatastart+seclist[i][1]] + i = 0 + while 1: + chunk = idata[i*20:(i+1)*20] + if len(chunk) != 20: + print "E: premature end of import table (chunk is %d, not 20)" % len(chunk) + break + vsa = struct.unpack('5l', chunk)[3] + if vsa == 0: + break + sa = raw + vsa - vbase + end = string.find(f, '\000', sa) + nm = f[sa:end] + if nm: + rslt.append(nm) + i = i + 1 + else: + print "E: bindepend cannot analyze %s - file is not in PE format!" % pth except IOError: print "E: bindepend cannot analyze %s - file not found!" % pth #except struct.error: @@ -264,23 +264,23 @@ def _getImports_pe(path): return dlls def Dependencies(lTOC, platform=sys.platform, xtrapath=None): - """Expand LTOC to include all the closure of binary dependencies. + """Expand LTOC to include all the closure of binary dependencies. - LTOC is a logical table of contents, ie, a seq of tuples (name, path). - Return LTOC expanded by all the binary dependencies of the entries - in LTOC, except those listed in the module global EXCLUDES""" - for nm, pth, typ in lTOC: - fullnm = string.upper(os.path.basename(pth)) - if seen.get(string.upper(nm),0): - continue - #print "I: analyzing", pth - seen[string.upper(nm)] = 1 - for lib, npth in selectImports(pth, platform, xtrapath): - if seen.get(string.upper(lib),0): + LTOC is a logical table of contents, ie, a seq of tuples (name, path). + Return LTOC expanded by all the binary dependencies of the entries + in LTOC, except those listed in the module global EXCLUDES""" + for nm, pth, typ in lTOC: + fullnm = string.upper(os.path.basename(pth)) + if seen.get(string.upper(nm),0): continue - lTOC.append((lib, npth, 'BINARY')) + #print "I: analyzing", pth + seen[string.upper(nm)] = 1 + for lib, npth in selectImports(pth, platform, xtrapath): + if seen.get(string.upper(lib),0): + continue + lTOC.append((lib, npth, 'BINARY')) - return lTOC + return lTOC def selectImports(pth, platform=sys.platform, xtrapath=None): """Return the dependencies of a binary that should be included. @@ -297,7 +297,7 @@ def selectImports(pth, platform=sys.platform, xtrapath=None): iswin = platform[:3] == 'win' for lib in dlls: if not iswin and not cygwin: - # plain win case + # plain win case npth = lib dir, lib = os.path.split(lib) if excludes.get(dir,0): @@ -305,7 +305,7 @@ def selectImports(pth, platform=sys.platform, xtrapath=None): else: # all other platforms npth = getfullnameof(lib, xtrapath) - + # now npth is a candidate lib # check again for excludes but with regex FIXME: split the list if excludesRe.search(npth): @@ -316,7 +316,7 @@ def selectImports(pth, platform=sys.platform, xtrapath=None): else: #print "I: inserting %20s <- %s" % (npth, pth) pass - + if npth: rv.append((lib, npth)) else: @@ -453,7 +453,7 @@ if __name__ == "__main__": parser = OptionParser(usage="%prog [options] ") parser.add_option('--target-platform', default=sys.platform, help='Target platform, required for cross-bundling (default: current platform)') - + opts, args = parser.parse_args() if len (args) != 1: parser.error('Requires exactly one filename') diff --git a/buildtests/pkg1/__init__.py b/buildtests/pkg1/__init__.py index 90ac1f0..55814c6 100644 --- a/buildtests/pkg1/__init__.py +++ b/buildtests/pkg1/__init__.py @@ -5,6 +5,3 @@ import pkg2 import sys sys.modules[__name__] = pkg2 from pkg2 import * - - - diff --git a/buildtests/pkg1/a.py b/buildtests/pkg1/a.py index 6832d26..c8cc68e 100644 --- a/buildtests/pkg1/a.py +++ b/buildtests/pkg1/a.py @@ -2,5 +2,3 @@ print " %s" % __doc__ print " %s %s" % (__name__, __file__) - - \ No newline at end of file diff --git a/buildtests/pkg2/a.py b/buildtests/pkg2/a.py index aefd456..5a94731 100644 --- a/buildtests/pkg2/a.py +++ b/buildtests/pkg2/a.py @@ -3,4 +3,3 @@ def a_func(): return "a_func from pkg2.a" print "pkg2.a imported" - diff --git a/buildtests/runtests.py b/buildtests/runtests.py index fc0b7c6..a9c5590 100644 --- a/buildtests/runtests.py +++ b/buildtests/runtests.py @@ -59,8 +59,8 @@ def runtests(alltests, filters=None): print "*"*len(info) print info print "*"*len(info) - build_python = open("python_exe.build", "w") - build_python.write(sys.executable) + build_python = open("python_exe.build", "w") + build_python.write(sys.executable) build_python.close() if not filters: tests = alltests @@ -96,7 +96,7 @@ if __name__ == '__main__': normal_tests = glob.glob('test*[0-9].py') interactive_tests = glob.glob('test*[0-9]i.py') args = sys.argv[1:] - + if "-i" in args: print "Running interactive tests" tests = interactive_tests @@ -106,4 +106,3 @@ if __name__ == '__main__': clean() runtests(tests) - diff --git a/buildtests/test13.py b/buildtests/test13.py index 4abc5fb..212a078 100644 --- a/buildtests/test13.py +++ b/buildtests/test13.py @@ -23,4 +23,3 @@ if sys.version_info[:2] >= (2, 5): print "test13 DONE" else: print "Python 2.5 test13 skipped" - diff --git a/buildtests/test14.py b/buildtests/test14.py index 5812690..3234544 100644 --- a/buildtests/test14.py +++ b/buildtests/test14.py @@ -19,7 +19,7 @@ print "test14 - Used to fail if _xmlplus is installed" import sys if sys.version_info[:2] >= (2, 5): - import subprocess + import subprocess import xml.etree.ElementTree as ET print "#"*50 print "xml.etree.ElementTree", dir(ET) @@ -35,4 +35,3 @@ if sys.version_info[:2] >= (2, 5): print "test14 DONE" else: print "Python 2.5 test14 skipped" - diff --git a/buildtests/test15.py b/buildtests/test15.py index c236349..ea834b5 100644 --- a/buildtests/test15.py +++ b/buildtests/test15.py @@ -32,4 +32,3 @@ if sys.version_info[:2] >= (2, 5): print "test15 DONE" else: print "Python 2.5 test14 skipped" - diff --git a/buildtests/test16.py b/buildtests/test16.py index 9fea929..ec51815 100644 --- a/buildtests/test16.py +++ b/buildtests/test16.py @@ -32,4 +32,3 @@ else: # as in setuptools/site.py print "test16 DONE" - diff --git a/buildtests/test6.py b/buildtests/test6.py index 4c16a28..962e5d4 100644 --- a/buildtests/test6.py +++ b/buildtests/test6.py @@ -26,4 +26,3 @@ else: open(test6x.__file__, 'w').write(txt) reload(test6x) print "test6x.x is now", test6x.x - diff --git a/buildtests/test7.py b/buildtests/test7.py index db9002a..cbd6de7 100644 --- a/buildtests/test7.py +++ b/buildtests/test7.py @@ -29,4 +29,3 @@ t2.start() doit('main') t1.join() t2.join() - diff --git a/carchive.py b/carchive.py index f9af276..12564d1 100644 --- a/carchive.py +++ b/carchive.py @@ -18,9 +18,9 @@ import archive import struct try: - import zlib + import zlib except ImportError: - zlib = archive.DummyZlib() + zlib = archive.DummyZlib() import sys if sys.version[0] == '1': import strop @@ -33,241 +33,241 @@ else: return s.split(delim, count) class CTOC: - """A class encapsulating the table of contents of a CArchive. + """A class encapsulating the table of contents of a CArchive. - When written to disk, it is easily read from C.""" - ENTRYSTRUCT = '!iiiibc' #(structlen, dpos, dlen, ulen, flag, typcd) followed by name - def __init__(self): - self.data = [] + When written to disk, it is easily read from C.""" + ENTRYSTRUCT = '!iiiibc' #(structlen, dpos, dlen, ulen, flag, typcd) followed by name + def __init__(self): + self.data = [] - def frombinary(self, s): - """Decode the binary string into an in memory list. + def frombinary(self, s): + """Decode the binary string into an in memory list. - S is a binary string.""" - entrylen = struct.calcsize(self.ENTRYSTRUCT) - p = 0 - while p -1: - typcd = 'M' - self.toc.add(where, dlen, ulen, flag, typcd, nm) - self.lib.write(s) + ENTRY must have: + entry[0] is name (under which it will be saved). + entry[1] is fullpathname of the file. + entry[2] is a flag for it's storage format (0==uncompressed, + 1==compressed) + entry[3] is the entry's type code. + Version 5: + If the type code is 'o': + entry[0] is the runtime option + eg: v (meaning verbose imports) + u (menaing unbuffered) + W arg (warning option arg) + s (meaning do site.py processing.""" + (nm, pathnm, flag, typcd) = entry[:4] + # version 5 - allow type 'o' = runtime option + try: + if typcd == 'o': + s = '' + flag = 0 + elif typcd == 's': + # If it's a source code file, add \0 terminator as it will be + # executed as-is by the bootloader. + s = open(pathnm, 'r').read() + s = s + '\n\0' + else: + s = open(pathnm, 'rb').read() + except IOError: + print "Cannot find ('%s', '%s', %s, '%s')" % (nm, pathnm, flag, typcd) + raise + ulen = len(s) + if flag == 1: + s = zlib.compress(s, self.LEVEL) + dlen = len(s) + where = self.lib.tell() + if typcd == 'm': + if find(pathnm, '.__init__.py') > -1: + typcd = 'M' + self.toc.add(where, dlen, ulen, flag, typcd, nm) + self.lib.write(s) - def save_toc(self, tocpos): - """Save the table of contents to disk.""" - self.tocpos = tocpos - tocstr = self.toc.tobinary() - self.toclen = len(tocstr) - self.lib.write(tocstr) + def save_toc(self, tocpos): + """Save the table of contents to disk.""" + self.tocpos = tocpos + tocstr = self.toc.tobinary() + self.toclen = len(tocstr) + self.lib.write(tocstr) - def save_trailer(self, tocpos): - """Save the trailer to disk. + def save_trailer(self, tocpos): + """Save the trailer to disk. - CArchives can be opened from the end - the trailer points - back to the start. """ - totallen = tocpos + self.toclen + self.TRLLEN - if hasattr(sys, "version_info"): - pyvers = sys.version_info[0]*10 + sys.version_info[1] - else: - toks = split(sys.version, '.', 2) - pyvers = int(toks[0])*10 + int(toks[1]) - trl = struct.pack(self.TRLSTRUCT, self.MAGIC, totallen, - tocpos, self.toclen, pyvers) - self.lib.write(trl) + CArchives can be opened from the end - the trailer points + back to the start. """ + totallen = tocpos + self.toclen + self.TRLLEN + if hasattr(sys, "version_info"): + pyvers = sys.version_info[0]*10 + sys.version_info[1] + else: + toks = split(sys.version, '.', 2) + pyvers = int(toks[0])*10 + int(toks[1]) + trl = struct.pack(self.TRLSTRUCT, self.MAGIC, totallen, + tocpos, self.toclen, pyvers) + self.lib.write(trl) - def openEmbedded(self, name): - """Open a CArchive of name NAME embedded within this CArchive.""" - ndx = self.toc.find(name) - if ndx == -1: - raise KeyError, "Member '%s' not found in %s" % (name, self.path) - (dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx) - if flag: - raise ValueError, "Cannot open compressed archive %s in place" - return CArchive(self.path, self.pkgstart+dpos, dlen) + def openEmbedded(self, name): + """Open a CArchive of name NAME embedded within this CArchive.""" + ndx = self.toc.find(name) + if ndx == -1: + raise KeyError, "Member '%s' not found in %s" % (name, self.path) + (dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx) + if flag: + raise ValueError, "Cannot open compressed archive %s in place" + return CArchive(self.path, self.pkgstart+dpos, dlen) diff --git a/doc/source/tools/buildrecursive.py b/doc/source/tools/buildrecursive.py index c1596ed..6a48fce 100755 --- a/doc/source/tools/buildrecursive.py +++ b/doc/source/tools/buildrecursive.py @@ -31,18 +31,18 @@ import os import os.path import copy try: - import docutils - from docutils import ApplicationError - from docutils import core, frontend - from docutils.parsers import rst - from docutils.readers import standalone, pep - from docutils.writers import html4css1, pep_html + import docutils + from docutils import ApplicationError + from docutils import core, frontend + from docutils.parsers import rst + from docutils.readers import standalone, pep + from docutils.writers import html4css1, pep_html except: - print "################################################################" - print "# You need 'docutils' installed to execute this program. #" - print "# 'docutils' is available from http://docutils.sourceforge.net #" - print "################################################################" - sys.exit(1) + print "################################################################" + print "# You need 'docutils' installed to execute this program. #" + print "# 'docutils' is available from http://docutils.sourceforge.net #" + print "################################################################" + sys.exit(1) usage = '%prog [options] [ ...]' diff --git a/e2etests/common/hanoi.py b/e2etests/common/hanoi.py index 9e566c4..078c246 100644 --- a/e2etests/common/hanoi.py +++ b/e2etests/common/hanoi.py @@ -16,139 +16,139 @@ from Tkinter import * # Basic Towers-of-Hanoi algorithm: move n pieces from a to b, using c # as temporary. For each move, call report() def hanoi(n, a, b, c, report): - if n <= 0: return - hanoi(n-1, a, c, b, report) - report(n, a, b) - hanoi(n-1, c, b, a, report) + if n <= 0: return + hanoi(n-1, a, c, b, report) + report(n, a, b) + hanoi(n-1, c, b, a, report) # The graphical interface class Tkhanoi: - # Create our objects - def __init__(self, n, bitmap = None): - self.n = n - self.tk = tk = Tk() - self.canvas = c = Canvas(tk) - c.pack() - width, height = tk.getint(c['width']), tk.getint(c['height']) + # Create our objects + def __init__(self, n, bitmap = None): + self.n = n + self.tk = tk = Tk() + self.canvas = c = Canvas(tk) + c.pack() + width, height = tk.getint(c['width']), tk.getint(c['height']) - # Add background bitmap - if bitmap: - self.bitmap = c.create_bitmap(width/2, height/2, - bitmap=bitmap, - foreground='blue') + # Add background bitmap + if bitmap: + self.bitmap = c.create_bitmap(width/2, height/2, + bitmap=bitmap, + foreground='blue') - # Generate pegs - pegwidth = 10 - pegheight = height/2 - pegdist = width/3 - x1, y1 = (pegdist-pegwidth)/2, height*1/3 - x2, y2 = x1+pegwidth, y1+pegheight - self.pegs = [] - p = c.create_rectangle(x1, y1, x2, y2, fill='black') - self.pegs.append(p) - x1, x2 = x1+pegdist, x2+pegdist - p = c.create_rectangle(x1, y1, x2, y2, fill='black') - self.pegs.append(p) - x1, x2 = x1+pegdist, x2+pegdist - p = c.create_rectangle(x1, y1, x2, y2, fill='black') - self.pegs.append(p) - self.tk.update() + # Generate pegs + pegwidth = 10 + pegheight = height/2 + pegdist = width/3 + x1, y1 = (pegdist-pegwidth)/2, height*1/3 + x2, y2 = x1+pegwidth, y1+pegheight + self.pegs = [] + p = c.create_rectangle(x1, y1, x2, y2, fill='black') + self.pegs.append(p) + x1, x2 = x1+pegdist, x2+pegdist + p = c.create_rectangle(x1, y1, x2, y2, fill='black') + self.pegs.append(p) + x1, x2 = x1+pegdist, x2+pegdist + p = c.create_rectangle(x1, y1, x2, y2, fill='black') + self.pegs.append(p) + self.tk.update() - # Generate pieces - pieceheight = pegheight/16 - maxpiecewidth = pegdist*2/3 - minpiecewidth = 2*pegwidth - self.pegstate = [[], [], []] - self.pieces = {} - x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 - x2, y2 = x1+maxpiecewidth, y1+pieceheight - dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) - for i in range(n, 0, -1): - p = c.create_rectangle(x1, y1, x2, y2, fill='red') - self.pieces[i] = p - self.pegstate[0].append(i) - x1, x2 = x1 + dx, x2-dx - y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 - self.tk.update() - self.tk.after(25) + # Generate pieces + pieceheight = pegheight/16 + maxpiecewidth = pegdist*2/3 + minpiecewidth = 2*pegwidth + self.pegstate = [[], [], []] + self.pieces = {} + x1, y1 = (pegdist-maxpiecewidth)/2, y2-pieceheight-2 + x2, y2 = x1+maxpiecewidth, y1+pieceheight + dx = (maxpiecewidth-minpiecewidth) / (2*max(1, n-1)) + for i in range(n, 0, -1): + p = c.create_rectangle(x1, y1, x2, y2, fill='red') + self.pieces[i] = p + self.pegstate[0].append(i) + x1, x2 = x1 + dx, x2-dx + y1, y2 = y1 - pieceheight-2, y2-pieceheight-2 + self.tk.update() + self.tk.after(25) - # Run -- never returns - def run(self): - while 1: - hanoi(self.n, 0, 1, 2, self.report) - hanoi(self.n, 1, 2, 0, self.report) - hanoi(self.n, 2, 0, 1, self.report) - hanoi(self.n, 0, 2, 1, self.report) - hanoi(self.n, 2, 1, 0, self.report) - hanoi(self.n, 1, 0, 2, self.report) + # Run -- never returns + def run(self): + while 1: + hanoi(self.n, 0, 1, 2, self.report) + hanoi(self.n, 1, 2, 0, self.report) + hanoi(self.n, 2, 0, 1, self.report) + hanoi(self.n, 0, 2, 1, self.report) + hanoi(self.n, 2, 1, 0, self.report) + hanoi(self.n, 1, 0, 2, self.report) - # Reporting callback for the actual hanoi function - def report(self, i, a, b): - if self.pegstate[a][-1] != i: raise RuntimeError # Assertion - del self.pegstate[a][-1] - p = self.pieces[i] - c = self.canvas + # Reporting callback for the actual hanoi function + def report(self, i, a, b): + if self.pegstate[a][-1] != i: raise RuntimeError # Assertion + del self.pegstate[a][-1] + p = self.pieces[i] + c = self.canvas - # Lift the piece above peg a - ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) - while 1: - x1, y1, x2, y2 = c.bbox(p) - if y2 < ay1: break - c.move(p, 0, -1) - self.tk.update() + # Lift the piece above peg a + ax1, ay1, ax2, ay2 = c.bbox(self.pegs[a]) + while 1: + x1, y1, x2, y2 = c.bbox(p) + if y2 < ay1: break + c.move(p, 0, -1) + self.tk.update() - # Move it towards peg b - bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) - newcenter = (bx1+bx2)/2 - while 1: - x1, y1, x2, y2 = c.bbox(p) - center = (x1+x2)/2 - if center == newcenter: break - if center > newcenter: c.move(p, -1, 0) - else: c.move(p, 1, 0) - self.tk.update() + # Move it towards peg b + bx1, by1, bx2, by2 = c.bbox(self.pegs[b]) + newcenter = (bx1+bx2)/2 + while 1: + x1, y1, x2, y2 = c.bbox(p) + center = (x1+x2)/2 + if center == newcenter: break + if center > newcenter: c.move(p, -1, 0) + else: c.move(p, 1, 0) + self.tk.update() - # Move it down on top of the previous piece - pieceheight = y2-y1 - newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 - while 1: - x1, y1, x2, y2 = c.bbox(p) - if y2 >= newbottom: break - c.move(p, 0, 1) - self.tk.update() + # Move it down on top of the previous piece + pieceheight = y2-y1 + newbottom = by2 - pieceheight*len(self.pegstate[b]) - 2 + while 1: + x1, y1, x2, y2 = c.bbox(p) + if y2 >= newbottom: break + c.move(p, 0, 1) + self.tk.update() - # Update peg state - self.pegstate[b].append(i) + # Update peg state + self.pegstate[b].append(i) # Main program def main(): - import sys, string + import sys, string - # First argument is number of pegs, default 4 - if sys.argv[1:]: - n = string.atoi(sys.argv[1]) - else: - n = 4 + # First argument is number of pegs, default 4 + if sys.argv[1:]: + n = string.atoi(sys.argv[1]) + else: + n = 4 - # Second argument is bitmap file, default none - if sys.argv[2:]: - bitmap = sys.argv[2] - # Reverse meaning of leading '@' compared to Tk - if bitmap[0] == '@': bitmap = bitmap[1:] - else: bitmap = '@' + bitmap - else: - bitmap = None + # Second argument is bitmap file, default none + if sys.argv[2:]: + bitmap = sys.argv[2] + # Reverse meaning of leading '@' compared to Tk + if bitmap[0] == '@': bitmap = bitmap[1:] + else: bitmap = '@' + bitmap + else: + bitmap = None - # Create the graphical objects... - h = Tkhanoi(n, bitmap) + # Create the graphical objects... + h = Tkhanoi(n, bitmap) - # ...and run! - h.run() + # ...and run! + h.run() # Call main when run as script if __name__ == '__main__': - main() + main() diff --git a/e2etests/common/maketests.py b/e2etests/common/maketests.py index 066a4c9..5d84de9 100644 --- a/e2etests/common/maketests.py +++ b/e2etests/common/maketests.py @@ -48,4 +48,3 @@ for bldconfig in ('--onedir', '--onefile'): else: os.system("ln -s /u/temp/t%d/hanoi hanoi%d" % (i,i)) i += 1 - diff --git a/e2etests/win32/NextID.py b/e2etests/win32/NextID.py index 98631ce..15d6f9a 100644 --- a/e2etests/win32/NextID.py +++ b/e2etests/win32/NextID.py @@ -76,4 +76,3 @@ if __name__ == '__main__': import win32com.server.localserver win32com.server.localserver.main() raw_input("Press any key...") - diff --git a/e2etests/win32/testMSOffice.py b/e2etests/win32/testMSOffice.py index b2232f8..d0731d8 100644 --- a/e2etests/win32/testMSOffice.py +++ b/e2etests/win32/testMSOffice.py @@ -34,166 +34,165 @@ error = "MSOffice test error" # Test a few of the MSOffice components. def TestWord(): - # Try and load the object exposed by Word 8 - # Office 97 - _totally_ different object model! - try: - # NOTE - using "client.Dispatch" would return an msword8.py instance! - print "Starting Word 8 for dynamic test" - word = win32com.client.dynamic.Dispatch("Word.Application") - TestWord8(word) + # Try and load the object exposed by Word 8 + # Office 97 - _totally_ different object model! + try: + # NOTE - using "client.Dispatch" would return an msword8.py instance! + print "Starting Word 8 for dynamic test" + word = win32com.client.dynamic.Dispatch("Word.Application") + TestWord8(word) - word = None - # Now we will test Dispatch without the new "lazy" capabilities - print "Starting Word 8 for non-lazy dynamic test" - dispatch = win32com.client.dynamic._GetGoodDispatch("Word.Application") - typeinfo = dispatch.GetTypeInfo() - attr = typeinfo.GetTypeAttr() - olerepr = win32com.client.build.DispatchItem(typeinfo, attr, None, 0) - word = win32com.client.dynamic.CDispatch(dispatch, olerepr) - dispatch = typeinfo = attr = olerepr = None - TestWord8(word) + word = None + # Now we will test Dispatch without the new "lazy" capabilities + print "Starting Word 8 for non-lazy dynamic test" + dispatch = win32com.client.dynamic._GetGoodDispatch("Word.Application") + typeinfo = dispatch.GetTypeInfo() + attr = typeinfo.GetTypeAttr() + olerepr = win32com.client.build.DispatchItem(typeinfo, attr, None, 0) + word = win32com.client.dynamic.CDispatch(dispatch, olerepr) + dispatch = typeinfo = attr = olerepr = None + TestWord8(word) - except pythoncom.com_error: - print "Starting Word 7 for dynamic test" - word = win32com.client.Dispatch("Word.Basic") - TestWord7(word) + except pythoncom.com_error: + print "Starting Word 7 for dynamic test" + word = win32com.client.Dispatch("Word.Basic") + TestWord7(word) - try: - print "Starting MSWord for generated test" - # Typelib, lcid, major and minor for the typelib - try: - o = gencache.EnsureModule("{00020905-0000-0000-C000-000000000046}", 1033, 8, 0, bForDemand=1) - except TypeError: - o = gencache.EnsureModule("{00020905-0000-0000-C000-000000000046}", 1033, 8, 0) - if o is None : - raise ImportError, "Can not load the Word8 typelibrary." - word = win32com.client.Dispatch("Word.Application.8") - TestWord8(word) - except ImportError, details: - print "Can not test MSWord8 -", details + try: + print "Starting MSWord for generated test" + # Typelib, lcid, major and minor for the typelib + try: + o = gencache.EnsureModule("{00020905-0000-0000-C000-000000000046}", 1033, 8, 0, bForDemand=1) + except TypeError: + o = gencache.EnsureModule("{00020905-0000-0000-C000-000000000046}", 1033, 8, 0) + if o is None : + raise ImportError, "Can not load the Word8 typelibrary." + word = win32com.client.Dispatch("Word.Application.8") + TestWord8(word) + except ImportError, details: + print "Can not test MSWord8 -", details def TestWord7(word): - word.FileNew() - # If not shown, show the app. - if not word.AppShow(): word._proc_("AppShow") + word.FileNew() + # If not shown, show the app. + if not word.AppShow(): word._proc_("AppShow") - for i in xrange(12): - word.FormatFont(Color=i+1, Points=i+12) - word.Insert("Hello from Python %d\n" % i) + for i in xrange(12): + word.FormatFont(Color=i+1, Points=i+12) + word.Insert("Hello from Python %d\n" % i) - word.FileClose(2) + word.FileClose(2) def TestWord8(word): - word.Visible = 1 - doc = word.Documents.Add() - wrange = doc.Range() - for i in range(10): - wrange.InsertAfter("Hello from Python %d\n" % i) - paras = doc.Paragraphs - for i in range(len(paras)): - paras[i]().Font.ColorIndex = i+1 - paras[i]().Font.Size = 12 + (4 * i) - # XXX - note that - # for para in paras: - # para().Font... - # doesnt seem to work - no error, just doesnt work - # Should check if it works for VB! - doc.Close(SaveChanges = 0) - word.Quit() - win32api.Sleep(1000) # Wait for word to close, else we - # may get OA error. + word.Visible = 1 + doc = word.Documents.Add() + wrange = doc.Range() + for i in range(10): + wrange.InsertAfter("Hello from Python %d\n" % i) + paras = doc.Paragraphs + for i in range(len(paras)): + paras[i]().Font.ColorIndex = i+1 + paras[i]().Font.Size = 12 + (4 * i) + # XXX - note that + # for para in paras: + # para().Font... + # doesnt seem to work - no error, just doesnt work + # Should check if it works for VB! + doc.Close(SaveChanges = 0) + word.Quit() + win32api.Sleep(1000) # Wait for word to close, else we + # may get OA error. def TestWord8OldStyle(): - try: - import win32com.test.Generated4Test.msword8 - except ImportError: - print "Can not do old style test" + try: + import win32com.test.Generated4Test.msword8 + except ImportError: + print "Can not do old style test" def TextExcel(xl): - xl.Visible = 0 - if xl.Visible: raise error, "Visible property is true." - xl.Visible = 1 - if not xl.Visible: raise error, "Visible property not true." + xl.Visible = 0 + if xl.Visible: raise error, "Visible property is true." + xl.Visible = 1 + if not xl.Visible: raise error, "Visible property not true." - if int(xl.Version[0])>=8: - xl.Workbooks.Add() - else: - xl.Workbooks().Add() + if int(xl.Version[0])>=8: + xl.Workbooks.Add() + else: + xl.Workbooks().Add() - xl.Range("A1:C1").Value = (1,2,3) - xl.Range("A2:C2").Value = ('x','y','z') - xl.Range("A3:C3").Value = ('3','2','1') + xl.Range("A1:C1").Value = (1,2,3) + xl.Range("A2:C2").Value = ('x','y','z') + xl.Range("A3:C3").Value = ('3','2','1') - for i in xrange(20): - xl.Cells(i+1,i+1).Value = "Hi %d" % i + for i in xrange(20): + xl.Cells(i+1,i+1).Value = "Hi %d" % i - if xl.Range("A1").Value <> "Hi 0": - raise error, "Single cell range failed" + if xl.Range("A1").Value <> "Hi 0": + raise error, "Single cell range failed" - if xl.Range("A1:B1").Value <> ((Unicode("Hi 0"),2),): - raise error, "flat-horizontal cell range failed" + if xl.Range("A1:B1").Value <> ((Unicode("Hi 0"),2),): + raise error, "flat-horizontal cell range failed" - if xl.Range("A1:A2").Value <> ((Unicode("Hi 0"),),(Unicode("x"),)): - raise error, "flat-vertical cell range failed" + if xl.Range("A1:A2").Value <> ((Unicode("Hi 0"),),(Unicode("x"),)): + raise error, "flat-vertical cell range failed" - if xl.Range("A1:C3").Value <> ((Unicode("Hi 0"),2,3),(Unicode("x"),Unicode("Hi 1"),Unicode("z")),(3,2,Unicode("Hi 2"))): - raise error, "square cell range failed" + if xl.Range("A1:C3").Value <> ((Unicode("Hi 0"),2,3),(Unicode("x"),Unicode("Hi 1"),Unicode("z")),(3,2,Unicode("Hi 2"))): + raise error, "square cell range failed" - xl.Range("A1:C3").Value =((3,2,1),("x","y","z"),(1,2,3)) + xl.Range("A1:C3").Value =((3,2,1),("x","y","z"),(1,2,3)) - if xl.Range("A1:C3").Value <> ((3,2,1),(Unicode("x"),Unicode("y"),Unicode("z")),(1,2,3)): - raise error, "Range was not what I set it to!" + if xl.Range("A1:C3").Value <> ((3,2,1),(Unicode("x"),Unicode("y"),Unicode("z")),(1,2,3)): + raise error, "Range was not what I set it to!" - # test dates out with Excel - xl.Cells(5,1).Value = "Excel time" - xl.Cells(5,2).Formula = "=Now()" + # test dates out with Excel + xl.Cells(5,1).Value = "Excel time" + xl.Cells(5,2).Formula = "=Now()" - import time - xl.Cells(6,1).Value = "Python time" - xl.Cells(6,2).Value = pythoncom.MakeTime(time.time()) - xl.Cells(6,2).NumberFormat = "d/mm/yy h:mm" - xl.Columns("A:B").EntireColumn.AutoFit() + import time + xl.Cells(6,1).Value = "Python time" + xl.Cells(6,2).Value = pythoncom.MakeTime(time.time()) + xl.Cells(6,2).NumberFormat = "d/mm/yy h:mm" + xl.Columns("A:B").EntireColumn.AutoFit() - xl.Workbooks(1).Close(0) - xl.Quit() + xl.Workbooks(1).Close(0) + xl.Quit() def TestAll(): - try: - TestWord() + try: + TestWord() - print "Starting Excel for Dynamic test..." - xl = win32com.client.dynamic.Dispatch("Excel.Application") - TextExcel(xl) + print "Starting Excel for Dynamic test..." + xl = win32com.client.dynamic.Dispatch("Excel.Application") + TextExcel(xl) - try: - print "Starting Excel 8 for generated excel8.py test..." - try: - mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 0, 1, 2, bForDemand=1) - except TypeError: - mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 0, 1, 2) - xl = win32com.client.Dispatch("Excel.Application") - TextExcel(xl) - except ImportError: - print "Could not import the generated Excel 97 wrapper" + try: + print "Starting Excel 8 for generated excel8.py test..." + try: + mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 0, 1, 2, bForDemand=1) + except TypeError: + mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 0, 1, 2) + xl = win32com.client.Dispatch("Excel.Application") + TextExcel(xl) + except ImportError: + print "Could not import the generated Excel 97 wrapper" - try: - import xl5en32 - mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 9, 1, 0) - xl = win32com.client.Dispatch("Excel.Application.5") - print "Starting Excel 95 for makepy test..." - TextExcel(xl) - except ImportError: - print "Could not import the generated Excel 95 wrapper" + try: + import xl5en32 + mod = gencache.EnsureModule("{00020813-0000-0000-C000-000000000046}", 9, 1, 0) + xl = win32com.client.Dispatch("Excel.Application.5") + print "Starting Excel 95 for makepy test..." + TextExcel(xl) + except ImportError: + print "Could not import the generated Excel 95 wrapper" - except KeyboardInterrupt: - print "*** Interrupted MSOffice test ***" - except: - traceback.print_exc() + except KeyboardInterrupt: + print "*** Interrupted MSOffice test ***" + except: + traceback.print_exc() if __name__=='__main__': - TestAll() - CheckClean() - pythoncom.CoUninitialize() - + TestAll() + CheckClean() + pythoncom.CoUninitialize() diff --git a/hooks/hook-carchive.py b/hooks/hook-carchive.py index 43aec87..578bbcc 100644 --- a/hooks/hook-carchive.py +++ b/hooks/hook-carchive.py @@ -22,4 +22,3 @@ def hook(mod): if mod.imports[i][0] == 'strop': del mod.imports[i] return mod - diff --git a/hooks/hook-iu.py b/hooks/hook-iu.py index 33556ef..68b55b6 100644 --- a/hooks/hook-iu.py +++ b/hooks/hook-iu.py @@ -36,4 +36,3 @@ def hook(mod): if nm in removes: del mod.imports[i] return mod - diff --git a/hooks/hook-os.py b/hooks/hook-os.py index 7c3f5b6..c95b697 100644 --- a/hooks/hook-os.py +++ b/hooks/hook-os.py @@ -41,4 +41,3 @@ def hook(mod): if nm in removes : del mod.imports[i] return mod - diff --git a/hooks/hook-pythoncom.py b/hooks/hook-pythoncom.py index 23db67e..4abbd76 100644 --- a/hooks/hook-pythoncom.py +++ b/hooks/hook-pythoncom.py @@ -36,4 +36,3 @@ def hook(mod): import mf mod = mf.ExtensionModule(newname, pth) return mod - diff --git a/hooks/hook-vtkpython.py b/hooks/hook-vtkpython.py index 951d77b..3a8eb87 100644 --- a/hooks/hook-vtkpython.py +++ b/hooks/hook-vtkpython.py @@ -18,7 +18,6 @@ # courtesy of David C. Morrill (4/2/2002) import os if os.name == 'posix': - hiddenimports = ['libvtkCommonPython','libvtkFilteringPython','libvtkIOPython','libvtkImagingPython','libvtkGraphicsPython','libvtkRenderingPython','libvtkHybridPython','libvtkParallelPython','libvtkPatentedPython'] + hiddenimports = ['libvtkCommonPython','libvtkFilteringPython','libvtkIOPython','libvtkImagingPython','libvtkGraphicsPython','libvtkRenderingPython','libvtkHybridPython','libvtkParallelPython','libvtkPatentedPython'] else: - hiddenimports = ['vtkCommonPython','vtkFilteringPython','vtkIOPython','vtkImagingPython','vtkGraphicsPython','vtkRenderingPython','vtkHybridPython','vtkParallelPython','vtkPatentedPython'] - + hiddenimports = ['vtkCommonPython','vtkFilteringPython','vtkIOPython','vtkImagingPython','vtkGraphicsPython','vtkRenderingPython','vtkHybridPython','vtkParallelPython','vtkPatentedPython'] diff --git a/hooks/hook-xml.dom.html.HTMLDocument.py b/hooks/hook-xml.dom.html.HTMLDocument.py index 2db2f93..dde8639 100644 --- a/hooks/hook-xml.dom.html.HTMLDocument.py +++ b/hooks/hook-xml.dom.html.HTMLDocument.py @@ -70,5 +70,3 @@ hiddenimports = ['xml.dom.html.HTMLAnchorElement', 'xml.dom.html.HTMLTitleElement', 'xml.dom.html.HTMLUListElement', ] - - diff --git a/hooks/hook-xml.dom.html.py b/hooks/hook-xml.dom.html.py index fc75593..b769d83 100644 --- a/hooks/hook-xml.dom.html.py +++ b/hooks/hook-xml.dom.html.py @@ -31,5 +31,3 @@ attrs = [('HTML_4_STRICT_INLINE',0), ('TranslateHtmlCdata',0), ('SECURE_HTML_ELEMS',0), ] - - diff --git a/hooks/hook-xml.etree.cElementTree.py b/hooks/hook-xml.etree.cElementTree.py index 827e19b..face9e9 100644 --- a/hooks/hook-xml.etree.cElementTree.py +++ b/hooks/hook-xml.etree.cElementTree.py @@ -17,4 +17,3 @@ # cElementTree has a hidden import (Python >=2.5 stdlib version) hiddenimports = ['xml.etree.ElementTree'] - diff --git a/icon.py b/icon.py index f4b8ff1..e72a700 100644 --- a/icon.py +++ b/icon.py @@ -153,4 +153,3 @@ def CopyIcons (dstpath, srcpath): win32api.UpdateResource (hdst, RT_ICON, iconname, data) win32api.FreeLibrary (hsrc) win32api.EndUpdateResource (hdst, 0) - diff --git a/iu.py b/iu.py index a1a1cd2..1e432f4 100644 --- a/iu.py +++ b/iu.py @@ -602,7 +602,7 @@ def _string_bootstrap(): def join(sep, words): res = '' for w in words: - res = res + (sep + w) + res = res + (sep + w) return res[len(sep):] _string_join = join @@ -613,19 +613,19 @@ def _string_bootstrap(): res = [] nsep = len(sep) if nsep == 0: - return [s] + return [s] ns = len(s) if maxsplit <= 0: maxsplit = ns i = j = 0 count = 0 while j+nsep <= ns: - if s[j:j+nsep] == sep: - count = count + 1 - res.append(s[i:j]) - i = j = j + nsep - if count >= maxsplit: break - else: - j = j + 1 + if s[j:j+nsep] == sep: + count = count + 1 + res.append(s[i:j]) + i = j = j + nsep + if count >= maxsplit: break + else: + j = j + 1 res.append(s[i:]) return res _string_split = split diff --git a/mf.py b/mf.py index 13097bd..d7bace1 100644 --- a/mf.py +++ b/mf.py @@ -243,7 +243,7 @@ class RegistryImportDirector(ImportDirector): stuff = open(fnm, 'rb').read() co = loadco(stuff[8:]) return PyModule(nm, fnm, co) - return None + return None class PathImportDirector(ImportDirector): def __init__(self, pathlist=None, importers=None, ownertypes=None): diff --git a/source/linux/Make.py b/source/linux/Make.py index 32a9bef..c0c32e4 100644 --- a/source/linux/Make.py +++ b/source/linux/Make.py @@ -34,10 +34,10 @@ import makemakefile import pprint try: - from distutils import sysconfig + from distutils import sysconfig except: - print "ERROR: distutils with sysconfig required" - sys.exit(1) + print "ERROR: distutils with sysconfig required" + sys.exit(1) try: True @@ -98,15 +98,15 @@ def main(): config_h_dir = exec_prefix makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') else: -# binlib = os.path.join (sysconfig.get_python_lib(True, True, exec_prefix), 'config') - binlib = sysconfig.get_config_vars('LIBDIR')[0] - # TODO: Is it possible to have more than one path returned? if so fix "includes" list - incldir_list = sysconfig.get_config_vars('INCLUDEDIR') - includes = [] - for dir in incldir_list: - if dir != None: - includes.append('-I' + dir) - config_h_dir = os.path.join (sysconfig.get_python_inc(True,exec_prefix)) +# binlib = os.path.join (sysconfig.get_python_lib(True, True, exec_prefix), 'config') + binlib = sysconfig.get_config_vars('LIBDIR')[0] + # TODO: Is it possible to have more than one path returned? if so fix "includes" list + incldir_list = sysconfig.get_config_vars('INCLUDEDIR') + includes = [] + for dir in incldir_list: + if dir != None: + includes.append('-I' + dir) + config_h_dir = os.path.join (sysconfig.get_python_inc(True,exec_prefix)) includes.append('-I' + config_h_dir) makefile_in = sysconfig.get_makefile_filename() diff --git a/source/linux/bkfile.py b/source/linux/bkfile.py index 07923e1..0a1416c 100644 --- a/source/linux/bkfile.py +++ b/source/linux/bkfile.py @@ -18,54 +18,54 @@ _orig_open = open class _BkFile: - def __init__(self, file, mode, bufsize): - import os - self.__filename = file - self.__backup = file + '~' - try: - os.unlink(self.__backup) - except os.error: - pass - try: - os.rename(file, self.__backup) - except os.error: - self.__backup = None - self.__file = _orig_open(file, mode, bufsize) - self.closed = self.__file.closed - self.fileno = self.__file.fileno - self.flush = self.__file.flush - self.isatty = self.__file.isatty - self.mode = self.__file.mode - self.name = self.__file.name - self.read = self.__file.read - self.readinto = self.__file.readinto - self.readline = self.__file.readline - self.readlines = self.__file.readlines - self.seek = self.__file.seek - self.softspace = self.__file.softspace - self.tell = self.__file.tell - self.truncate = self.__file.truncate - self.write = self.__file.write - self.writelines = self.__file.writelines + def __init__(self, file, mode, bufsize): + import os + self.__filename = file + self.__backup = file + '~' + try: + os.unlink(self.__backup) + except os.error: + pass + try: + os.rename(file, self.__backup) + except os.error: + self.__backup = None + self.__file = _orig_open(file, mode, bufsize) + self.closed = self.__file.closed + self.fileno = self.__file.fileno + self.flush = self.__file.flush + self.isatty = self.__file.isatty + self.mode = self.__file.mode + self.name = self.__file.name + self.read = self.__file.read + self.readinto = self.__file.readinto + self.readline = self.__file.readline + self.readlines = self.__file.readlines + self.seek = self.__file.seek + self.softspace = self.__file.softspace + self.tell = self.__file.tell + self.truncate = self.__file.truncate + self.write = self.__file.write + self.writelines = self.__file.writelines - def close(self): - self.__file.close() - if self.__backup is None: - return - try: - from cmp import do_cmp - except: - from filecmp import cmp - do_cmp = cmp - # don't use cmp.cmp because of NFS bugs :-( and - # anyway, the stat mtime values differ so do_cmp will - # most likely be called anyway - if do_cmp(self.__backup, self.__filename): - import os - os.unlink(self.__filename) - os.rename(self.__backup, self.__filename) + def close(self): + self.__file.close() + if self.__backup is None: + return + try: + from cmp import do_cmp + except: + from filecmp import cmp + do_cmp = cmp + # don't use cmp.cmp because of NFS bugs :-( and + # anyway, the stat mtime values differ so do_cmp will + # most likely be called anyway + if do_cmp(self.__backup, self.__filename): + import os + os.unlink(self.__filename) + os.rename(self.__backup, self.__filename) def open(file, mode = 'r', bufsize = -1): - if 'w' not in mode: - return _orig_open(file, mode, bufsize) - return _BkFile(file, mode, bufsize) + if 'w' not in mode: + return _orig_open(file, mode, bufsize) + return _BkFile(file, mode, bufsize) diff --git a/source/linux/makemakefile.py b/source/linux/makemakefile.py index 721df4a..38dc9aa 100644 --- a/source/linux/makemakefile.py +++ b/source/linux/makemakefile.py @@ -44,5 +44,3 @@ def writerules(outfp, files, suffix, dflag, target): outfp.write("\n%s: %s\n" % (target, string.join(deps))) outfp.write("\t$(CC) %s -o %s $(LDLAST)\n" % (string.join(files), target)) - - diff --git a/support/removeTK.py b/support/removeTK.py index 3b33fc8..2e3abaa 100644 --- a/support/removeTK.py +++ b/support/removeTK.py @@ -48,4 +48,3 @@ prvtdir = os.path.dirname(tcldir) if os.path.basename(prvtdir) == '_MEI': empty(prvtdir) os.rmdir(prvtdir) - diff --git a/support/rthooks/win32comgenpy.py b/support/rthooks/win32comgenpy.py index 0ca03da..9f9de97 100644 --- a/support/rthooks/win32comgenpy.py +++ b/support/rthooks/win32comgenpy.py @@ -36,4 +36,3 @@ win32com.__gen_path__ = genpydir win32com.__path__.insert(0, supportdir) # for older Pythons import copy_reg - diff --git a/support/unpackTK.py b/support/unpackTK.py index 61385e3..906f3e3 100644 --- a/support/unpackTK.py +++ b/support/unpackTK.py @@ -37,4 +37,3 @@ for fnm in tk.contents(): os.makedirs(dirnm) open(outnm, 'wb').write(stuff) tk = None - diff --git a/versionInfo.py b/versionInfo.py index 5f3d659..87f9ecc 100644 --- a/versionInfo.py +++ b/versionInfo.py @@ -528,4 +528,3 @@ if __name__ == '__main__': else: print "Examining", sys.argv[1] decode(sys.argv[1]) -