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 |
|
14 |
from __future__ import with_statement |
15 |
import os |
15 |
import os |
16 |
import sys |
16 |
import sys |
17 |
import py_compile |
17 |
import py_compile |
|
|
18 |
import struct |
19 |
import imp |
18 |
|
20 |
|
19 |
__all__ = ["compile_dir","compile_path"] |
21 |
__all__ = ["compile_dir","compile_path"] |
20 |
|
22 |
|
Lines 54-64
Link Here
|
54 |
if os.path.isfile(fullname): |
56 |
if os.path.isfile(fullname): |
55 |
head, tail = name[:-3], name[-3:] |
57 |
head, tail = name[:-3], name[-3:] |
56 |
if tail == '.py': |
58 |
if tail == '.py': |
57 |
cfile = fullname + (__debug__ and 'c' or 'o') |
59 |
if not force: |
58 |
ftime = os.stat(fullname).st_mtime |
60 |
try: |
59 |
try: ctime = os.stat(cfile).st_mtime |
61 |
mtime = os.stat(fullname).st_mtime |
60 |
except os.error: ctime = 0 |
62 |
expect = struct.pack('<4sl', imp.get_magic(), mtime) |
61 |
if (ctime > ftime) and not force: continue |
63 |
cfile = fullname + (__debug__ and 'c' or 'o') |
|
|
64 |
with open(cfile, 'rb') as chandle: |
65 |
actual = chandle.read(8) |
66 |
if expect == actual: |
67 |
continue |
68 |
except IOError: |
69 |
pass |
62 |
if not quiet: |
70 |
if not quiet: |
63 |
print 'Compiling', fullname, '...' |
71 |
print 'Compiling', fullname, '...' |
64 |
try: |
72 |
try: |