summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/checkpyc.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-01-17 08:48:39 (GMT)
commit70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7 (patch)
treecf47b67db3753288cfd9fa2adc45e7c5cd2f8741 /Tools/scripts/checkpyc.py
parenta88854059309667092000da55d4d5a5804267e9f (diff)
downloadcpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.zip
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.gz
cpython-70c4378dbcfdcbeef6fb3aa348f32ed862fe8eb7.tar.bz2
Whitespace normalization.
Diffstat (limited to 'Tools/scripts/checkpyc.py')
-rwxr-xr-xTools/scripts/checkpyc.py102
1 files changed, 51 insertions, 51 deletions
diff --git a/Tools/scripts/checkpyc.py b/Tools/scripts/checkpyc.py
index 7be625c..b38b456 100755
--- a/Tools/scripts/checkpyc.py
+++ b/Tools/scripts/checkpyc.py
@@ -8,58 +8,58 @@ from stat import ST_MTIME
import imp
def main():
- silent = 0
- verbose = 0
- if sys.argv[1:]:
- if sys.argv[1] == '-v':
- verbose = 1
- elif sys.argv[1] == '-s':
- silent = 1
- MAGIC = imp.get_magic()
- if not silent:
- print 'Using MAGIC word', `MAGIC`
- for dirname in sys.path:
- try:
- names = os.listdir(dirname)
- except os.error:
- print 'Cannot list directory', `dirname`
- continue
- if not silent:
- print 'Checking', `dirname`, '...'
- names.sort()
- for name in names:
- if name[-3:] == '.py':
- name = os.path.join(dirname, name)
- try:
- st = os.stat(name)
- except os.error:
- print 'Cannot stat', `name`
- continue
- if verbose:
- print 'Check', `name`, '...'
- name_c = name + 'c'
- try:
- f = open(name_c, 'r')
- except IOError:
- print 'Cannot open', `name_c`
- continue
- magic_str = f.read(4)
- mtime_str = f.read(4)
- f.close()
- if magic_str <> MAGIC:
- print 'Bad MAGIC word in ".pyc" file',
- print `name_c`
- continue
- mtime = get_long(mtime_str)
- if mtime == 0 or mtime == -1:
- print 'Bad ".pyc" file', `name_c`
- elif mtime <> st[ST_MTIME]:
- print 'Out-of-date ".pyc" file',
- print `name_c`
+ silent = 0
+ verbose = 0
+ if sys.argv[1:]:
+ if sys.argv[1] == '-v':
+ verbose = 1
+ elif sys.argv[1] == '-s':
+ silent = 1
+ MAGIC = imp.get_magic()
+ if not silent:
+ print 'Using MAGIC word', `MAGIC`
+ for dirname in sys.path:
+ try:
+ names = os.listdir(dirname)
+ except os.error:
+ print 'Cannot list directory', `dirname`
+ continue
+ if not silent:
+ print 'Checking', `dirname`, '...'
+ names.sort()
+ for name in names:
+ if name[-3:] == '.py':
+ name = os.path.join(dirname, name)
+ try:
+ st = os.stat(name)
+ except os.error:
+ print 'Cannot stat', `name`
+ continue
+ if verbose:
+ print 'Check', `name`, '...'
+ name_c = name + 'c'
+ try:
+ f = open(name_c, 'r')
+ except IOError:
+ print 'Cannot open', `name_c`
+ continue
+ magic_str = f.read(4)
+ mtime_str = f.read(4)
+ f.close()
+ if magic_str <> MAGIC:
+ print 'Bad MAGIC word in ".pyc" file',
+ print `name_c`
+ continue
+ mtime = get_long(mtime_str)
+ if mtime == 0 or mtime == -1:
+ print 'Bad ".pyc" file', `name_c`
+ elif mtime <> st[ST_MTIME]:
+ print 'Out-of-date ".pyc" file',
+ print `name_c`
def get_long(s):
- if len(s) <> 4:
- return -1
- return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24)
+ if len(s) <> 4:
+ return -1
+ return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24)
main()