mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +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
|
@ -8,23 +8,23 @@ import re
|
|||
|
||||
|
||||
def main():
|
||||
for file in sys.argv[1:]:
|
||||
for filename in sys.argv[1:]:
|
||||
try:
|
||||
f = open(file, 'r')
|
||||
f = open(filename, 'r')
|
||||
except IOError, msg:
|
||||
print file, ': can\'t open :', msg
|
||||
print filename, ': can\'t open :', msg
|
||||
continue
|
||||
line = f.readline()
|
||||
if not re.match('^#! */usr/local/bin/python', line):
|
||||
print file, ': not a /usr/local/bin/python script'
|
||||
print filename, ': not a /usr/local/bin/python script'
|
||||
f.close()
|
||||
continue
|
||||
rest = f.read()
|
||||
f.close()
|
||||
line = re.sub('/usr/local/bin/python',
|
||||
'/usr/bin/env python', line)
|
||||
print file, ':', `line`
|
||||
f = open(file, "w")
|
||||
print filename, ':', `line`
|
||||
f = open(filename, "w")
|
||||
f.write(line)
|
||||
f.write(rest)
|
||||
f.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue