mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix use of 'file' as a variable name.
(I've tested the fixes, but please proofread anyway.)
This commit is contained in:
parent
bf1bef820c
commit
ac6df95d07
16 changed files with 108 additions and 107 deletions
|
@ -20,33 +20,33 @@ def main():
|
|||
if optname == '-t':
|
||||
tabsize = int(optvalue)
|
||||
|
||||
for file in args:
|
||||
process(file, tabsize)
|
||||
for filename in args:
|
||||
process(filename, tabsize)
|
||||
|
||||
def process(file, tabsize):
|
||||
def process(filename, tabsize):
|
||||
try:
|
||||
f = open(file)
|
||||
f = open(filename)
|
||||
text = f.read()
|
||||
f.close()
|
||||
except IOError, msg:
|
||||
print "%s: I/O error: %s" % (`file`, str(msg))
|
||||
print "%s: I/O error: %s" % (`filename`, str(msg))
|
||||
return
|
||||
newtext = text.expandtabs(tabsize)
|
||||
if newtext == text:
|
||||
return
|
||||
backup = file + "~"
|
||||
backup = filename + "~"
|
||||
try:
|
||||
os.unlink(backup)
|
||||
except os.error:
|
||||
pass
|
||||
try:
|
||||
os.rename(file, backup)
|
||||
os.rename(filename, backup)
|
||||
except os.error:
|
||||
pass
|
||||
f = open(file, "w")
|
||||
f = open(filename, "w")
|
||||
f.write(newtext)
|
||||
f.close()
|
||||
print file
|
||||
print filename
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue