Lines 11-20
Link Here
|
11 |
See module py_compile for details of the actual byte-compilation. |
11 |
See module py_compile for details of the actual byte-compilation. |
12 |
|
12 |
|
13 |
""" |
13 |
""" |
14 |
|
|
|
15 |
import os |
14 |
import os |
16 |
import sys |
15 |
import sys |
17 |
import py_compile |
16 |
import py_compile |
|
|
17 |
import struct |
18 |
import imp |
18 |
|
19 |
|
19 |
__all__ = ["compile_dir","compile_path"] |
20 |
__all__ = ["compile_dir","compile_path"] |
20 |
|
21 |
|
Lines 54-64
Link Here
|
54 |
if os.path.isfile(fullname): |
55 |
if os.path.isfile(fullname): |
55 |
head, tail = name[:-3], name[-3:] |
56 |
head, tail = name[:-3], name[-3:] |
56 |
if tail == '.py': |
57 |
if tail == '.py': |
57 |
cfile = fullname + (__debug__ and 'c' or 'o') |
58 |
if not force: |
58 |
ftime = os.stat(fullname).st_mtime |
59 |
try: |
59 |
try: ctime = os.stat(cfile).st_mtime |
60 |
mtime = os.stat(fullname).st_mtime |
60 |
except os.error: ctime = 0 |
61 |
expect = struct.pack('<4sl', imp.get_magic(), mtime) |
61 |
if (ctime > ftime) and not force: continue |
62 |
cfile = fullname + (__debug__ and 'c' or 'o') |
|
|
63 |
chandle = open(cfile, 'rb') |
64 |
try: |
65 |
actual = chandle.read(8) |
66 |
finally: |
67 |
chandle.close() |
68 |
if expect == actual: |
69 |
continue |
70 |
except IOError: |
71 |
pass |
62 |
if not quiet: |
72 |
if not quiet: |
63 |
print 'Compiling', fullname, '...' |
73 |
print 'Compiling', fullname, '...' |
64 |
try: |
74 |
try: |