1 #! /usr/local/bin/python
2 # Check that all ".pyc" files exist and are up-to-date
7 from stat
import ST_MTIME
13 if sys
.argv
[1] == '-v':
15 elif sys
.argv
[1] == '-s':
19 if sys
.version
[:5] >= '0.9.4':
20 MAGIC
= '\224\224\224\0'
24 print 'Using MAGIC word', `MAGIC`
25 for dirname
in sys
.path
:
27 names
= os
.listdir(dirname
)
29 print 'Cannot list directory', `dirname`
32 print 'Checking', `dirname`
, '...'
35 if name
[-3:] == '.py':
36 name
= os
.path
.join(dirname
, name
)
40 print 'Cannot stat', `name`
43 print 'Check', `name`
, '...'
48 print 'Cannot open', `name_c`
53 if magic_str
<> MAGIC
:
54 print 'Bad MAGIC word in ".pyc" file',
57 mtime
= get_long(mtime_str
)
58 if mtime
== 0 or mtime
== -1:
59 print 'Bad ".pyc" file', `name_c`
60 elif mtime
<> st
[ST_MTIME
]:
61 print 'Out-of-date ".pyc" file',
67 return ord(s
[0]) + (ord(s
[1])<<8) + (ord(s
[2])<<16) + (ord(s
[3])<<24)