mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
parent
ecfeb7f095
commit
70a6b49821
246 changed files with 926 additions and 962 deletions
|
@ -64,12 +64,12 @@ def ispython(name):
|
|||
return ispythonprog.match(name) >= 0
|
||||
|
||||
def recursedown(dirname):
|
||||
dbg('recursedown(' + `dirname` + ')\n')
|
||||
dbg('recursedown(%r)\n' % (dirname,))
|
||||
bad = 0
|
||||
try:
|
||||
names = os.listdir(dirname)
|
||||
except os.error, msg:
|
||||
err(dirname + ': cannot list directory: ' + `msg` + '\n')
|
||||
err('%s: cannot list directory: %r\n' % (dirname, msg))
|
||||
return 1
|
||||
names.sort()
|
||||
subdirs = []
|
||||
|
@ -86,11 +86,11 @@ def recursedown(dirname):
|
|||
return bad
|
||||
|
||||
def fix(filename):
|
||||
## dbg('fix(' + `filename` + ')\n')
|
||||
## dbg('fix(%r)\n' % (filename,))
|
||||
try:
|
||||
f = open(filename, 'r')
|
||||
except IOError, msg:
|
||||
err(filename + ': cannot open: ' + `msg` + '\n')
|
||||
err('%s: cannot open: %r\n' % (filename, msg))
|
||||
return 1
|
||||
line = f.readline()
|
||||
fixed = fixline(line)
|
||||
|
@ -104,7 +104,7 @@ def fix(filename):
|
|||
g = open(tempname, 'w')
|
||||
except IOError, msg:
|
||||
f.close()
|
||||
err(tempname+': cannot create: '+`msg`+'\n')
|
||||
err('%s: cannot create: %r\n' % (tempname, msg))
|
||||
return 1
|
||||
rep(filename + ': updating\n')
|
||||
g.write(fixed)
|
||||
|
@ -123,17 +123,17 @@ def fix(filename):
|
|||
statbuf = os.stat(filename)
|
||||
os.chmod(tempname, statbuf[ST_MODE] & 07777)
|
||||
except os.error, msg:
|
||||
err(tempname + ': warning: chmod failed (' + `msg` + ')\n')
|
||||
err('%s: warning: chmod failed (%r)\n' % (tempname, msg))
|
||||
# Then make a backup of the original file as filename~
|
||||
try:
|
||||
os.rename(filename, filename + '~')
|
||||
except os.error, msg:
|
||||
err(filename + ': warning: backup failed (' + `msg` + ')\n')
|
||||
err('%s: warning: backup failed (%r)\n' % (filename, msg))
|
||||
# Now move the temp file to the original file
|
||||
try:
|
||||
os.rename(tempname, filename)
|
||||
except os.error, msg:
|
||||
err(filename + ': rename failed (' + `msg` + ')\n')
|
||||
err('%s: rename failed (%r)\n' % (filename, msg))
|
||||
return 1
|
||||
# Return succes
|
||||
return 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue