2 # Check that all ".pyc" files exist and are up-to-date
7 from stat
import ST_MTIME
14 if sys
.argv
[1] == '-v':
16 elif sys
.argv
[1] == '-s':
18 MAGIC
= imp
.get_magic()
20 print 'Using MAGIC word', repr(MAGIC
)
21 for dirname
in sys
.path
:
23 names
= os
.listdir(dirname
)
25 print 'Cannot list directory', repr(dirname
)
28 print 'Checking ', repr(dirname
), '...'
31 if name
[-3:] == '.py':
32 name
= os
.path
.join(dirname
, name
)
36 print 'Cannot stat', repr(name
)
39 print 'Check', repr(name
), '...'
44 print 'Cannot open', repr(name_c
)
49 if magic_str
<> MAGIC
:
50 print 'Bad MAGIC word in ".pyc" file',
53 mtime
= get_long(mtime_str
)
54 if mtime
== 0 or mtime
== -1:
55 print 'Bad ".pyc" file', repr(name_c
)
56 elif mtime
<> st
[ST_MTIME
]:
57 print 'Out-of-date ".pyc" file',
63 return ord(s
[0]) + (ord(s
[1])<<8) + (ord(s
[2])<<16) + (ord(s
[3])<<24)
65 if __name__
== '__main__':