mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
Whitespace normalization.
This commit is contained in:
parent
a888540593
commit
70c4378dbc
57 changed files with 2434 additions and 2440 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue