26
--- Lib/compileall.py~ 2010-03-15 19:23:42.189842057 +0100
27
+++ Lib/compileall.py 2010-03-15 19:24:46.549844869 +0100
26
--- Lib/compileall.py.orig 2010-03-20 15:18:22.457061066 +0100
27
+++ Lib/compileall.py 2010-03-31 18:51:32.497377764 +0200
32
-__all__ = ["compile_dir","compile_path"]
33
+__all__ = ["compile_dir","compile_file","compile_path"]
35
def compile_dir(dir, maxlevels=10, ddir=None,
36
force=0, rx=None, quiet=0):
38
dfile = os.path.join(ddir, name)
42
- mo = rx.search(fullname)
45
- if os.path.isfile(fullname):
46
- head, tail = name[:-3], name[-3:]
48
- cfile = fullname + (__debug__ and 'c' or 'o')
49
- ftime = os.stat(fullname).st_mtime
50
- try: ctime = os.stat(cfile).st_mtime
51
- except os.error: ctime = 0
52
- if (ctime > ftime) and not force: continue
54
- print 'Compiling', fullname, '...'
56
- ok = py_compile.compile(fullname, None, dfile, True)
57
- except KeyboardInterrupt:
58
- raise KeyboardInterrupt
59
- except py_compile.PyCompileError,err:
61
- print 'Compiling', fullname, '...'
70
+ if not os.path.isdir(fullname):
71
+ if not compile_file(fullname, ddir, force, rx, quiet):
73
elif maxlevels > 0 and \
74
name != os.curdir and name != os.pardir and \
75
os.path.isdir(fullname) and \
80
+def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
81
+ """Byte-compile file.
82
+ file: the file to byte-compile
83
+ ddir: if given, purported directory name (this is the
84
+ directory name that will show up in error messages)
85
+ force: if 1, force compilation, even if timestamps are up-to-date
86
+ quiet: if 1, be quiet during compilation
91
+ name = os.path.basename(fullname)
92
+ if ddir is not None:
93
+ dfile = os.path.join(ddir, name)
97
+ mo = rx.search(fullname)
100
+ if os.path.isfile(fullname):
101
+ head, tail = name[:-3], name[-3:]
103
+ cfile = fullname + (__debug__ and 'c' or 'o')
104
+ ftime = os.stat(fullname).st_mtime
105
+ try: ctime = os.stat(cfile).st_mtime
106
+ except os.error: ctime = 0
107
+ if (ctime > ftime) and not force: return success
109
+ print 'Compiling', fullname, '...'
111
+ ok = py_compile.compile(fullname, None, dfile, True)
112
+ except KeyboardInterrupt:
113
+ raise KeyboardInterrupt
114
+ except py_compile.PyCompileError,err:
116
+ print 'Compiling', fullname, '...'
127
def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
128
"""Byte-compile all module on sys.path.
130
@@ -104,15 +125,34 @@
134
+def expand_args(args, flist):
135
+ """read names in flist and append to args"""
144
+ line = fd.readline()
147
+ expanded.append(line[:-1])
149
+ print "Error reading file list %s" % flist
154
"""Script main program."""
157
- opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:')
158
+ opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:i:')
159
except getopt.error, msg:
161
print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
162
- "[-x regexp] [directory ...]"
163
+ "[-x regexp] [-i list] [directory|file ...]"
164
print "-l: don't recurse down"
165
print "-f: force rebuild even if timestamps are up-to-date"
166
print "-q: quiet operation"
167
@@ -120,12 +160,14 @@
29
168
print " if no directory arguments, -l sys.path is assumed"
30
169
print "-x regexp: skip files matching the regular expression regexp"
31
170
print " the regexp is searched for in the full path of the file"