Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ac6df95

Browse files
committed
Fix use of 'file' as a variable name.
(I've tested the fixes, but please proofread anyway.)
1 parent bf1bef8 commit ac6df95

16 files changed

Lines changed: 108 additions & 107 deletions

Tools/scripts/byteyears.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@
3434

3535
# Compute max file name length
3636
maxlen = 1
37-
for file in sys.argv[1:]:
38-
if len(file) > maxlen: maxlen = len(file)
37+
for filename in sys.argv[1:]:
38+
maxlen = max(maxlen, len(filename))
3939

4040
# Process each argument in turn
41-
for file in sys.argv[1:]:
41+
for filename in sys.argv[1:]:
4242
try:
43-
st = statfunc(file)
43+
st = statfunc(filename)
4444
except os.error, msg:
45-
sys.stderr.write('can\'t stat ' + `file` + ': ' + `msg` + '\n')
45+
sys.stderr.write('can\'t stat ' + `filename` + ': ' + `msg` + '\n')
4646
status = 1
4747
st = ()
4848
if st:
4949
anytime = st[itime]
5050
size = st[ST_SIZE]
5151
age = now - anytime
5252
byteyears = float(size) * float(age) / secs_per_year
53-
print file.ljust(maxlen),
53+
print filename.ljust(maxlen),
5454
print repr(int(byteyears)).rjust(8)
5555

5656
sys.exit(status)

Tools/scripts/dutree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def main():
1111
while line[i] in '0123456789': i = i+1
1212
size = eval(line[:i])
1313
while line[i] in ' \t': i = i+1
14-
file = line[i:-1]
15-
comps = file.split('/')
14+
filename = line[i:-1]
15+
comps = filename.split('/')
1616
if comps[0] == '': comps[0] = '/'
1717
if comps[len(comps)-1] == '': del comps[len(comps)-1]
1818
total, d = store(size, comps, total, d)

Tools/scripts/eptags.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]'
2222
matcher = re.compile(expr)
2323

24-
def treat_file(file, outfp):
25-
"""Append tags found in file named 'file' to the open file 'outfp'"""
24+
def treat_file(filename, outfp):
25+
"""Append tags found in file named 'filename' to the open file 'outfp'"""
2626
try:
27-
fp = open(file, 'r')
27+
fp = open(filename, 'r')
2828
except:
29-
sys.stderr.write('Cannot open %s\n'%file)
29+
sys.stderr.write('Cannot open %s\n'%filename)
3030
return
3131
charno = 0
3232
lineno = 0
@@ -39,18 +39,18 @@ def treat_file(file, outfp):
3939
lineno = lineno + 1
4040
m = matcher.search(line)
4141
if m:
42-
tag = m.group(0) + '\177%d,%d\n'%(lineno,charno)
42+
tag = m.group(0) + '\177%d,%d\n' % (lineno, charno)
4343
tags.append(tag)
4444
size = size + len(tag)
4545
charno = charno + len(line)
46-
outfp.write('\f\n%s,%d\n'%(file,size))
46+
outfp.write('\f\n%s,%d\n' % (filename,size))
4747
for tag in tags:
4848
outfp.write(tag)
4949

5050
def main():
5151
outfp = open('TAGS', 'w')
52-
for file in sys.argv[1:]:
53-
treat_file(file, outfp)
52+
for filename in sys.argv[1:]:
53+
treat_file(filename, outfp)
5454

5555
if __name__=="__main__":
5656
main()

Tools/scripts/finddiv.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def main():
3737
if o == "-l":
3838
listnames = 1
3939
exit = None
40-
for file in args:
41-
x = process(file, listnames)
40+
for filename in args:
41+
x = process(filename, listnames)
4242
exit = exit or x
4343
return exit
4444

@@ -47,11 +47,11 @@ def usage(msg):
4747
sys.stderr.write("Usage: %s [-l] file ...\n" % sys.argv[0])
4848
sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0])
4949

50-
def process(file, listnames):
51-
if os.path.isdir(file):
52-
return processdir(file, listnames)
50+
def process(filename, listnames):
51+
if os.path.isdir(filename):
52+
return processdir(filename, listnames)
5353
try:
54-
fp = open(file)
54+
fp = open(filename)
5555
except IOError, msg:
5656
sys.stderr.write("Can't open: %s\n" % msg)
5757
return 1
@@ -60,11 +60,11 @@ def process(file, listnames):
6060
for type, token, (row, col), end, line in g:
6161
if token in ("/", "/="):
6262
if listnames:
63-
print file
63+
print filename
6464
break
6565
if row != lastrow:
6666
lastrow = row
67-
print "%s:%d:%s" % (file, row, line),
67+
print "%s:%d:%s" % (filename, row, line),
6868
fp.close()
6969

7070
def processdir(dir, listnames):

Tools/scripts/fixdiv.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def main():
164164
return
165165
files.sort()
166166
exit = None
167-
for file in files:
168-
x = process(file, warnings[file])
167+
for filename in files:
168+
x = process(filename, warnings[filename])
169169
exit = exit or x
170170
return exit
171171

@@ -194,23 +194,23 @@ def readwarnings(warningsfile):
194194
if line.find("division") >= 0:
195195
sys.stderr.write("Warning: ignored input " + line)
196196
continue
197-
file, lineno, what = m.groups()
198-
list = warnings.get(file)
197+
filename, lineno, what = m.groups()
198+
list = warnings.get(filename)
199199
if list is None:
200-
warnings[file] = list = []
200+
warnings[filename] = list = []
201201
list.append((int(lineno), intern(what)))
202202
f.close()
203203
return warnings
204204

205-
def process(file, list):
205+
def process(filename, list):
206206
print "-"*70
207207
assert list # if this fails, readwarnings() is broken
208208
try:
209-
fp = open(file)
209+
fp = open(filename)
210210
except IOError, msg:
211211
sys.stderr.write("can't open: %s\n" % msg)
212212
return 1
213-
print "Index:", file
213+
print "Index:", filename
214214
f = FileContext(fp)
215215
list.sort()
216216
index = 0 # list[:index] has been processed, list[index:] is still to do

Tools/scripts/fixheader.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66

77
def main():
88
args = sys.argv[1:]
9-
for file in args:
10-
process(file)
9+
for filename in args:
10+
process(filename)
1111

12-
def process(file):
12+
def process(filename):
1313
try:
14-
f = open(file, 'r')
14+
f = open(filename, 'r')
1515
except IOError, msg:
16-
sys.stderr.write('%s: can\'t open: %s\n' % (file, str(msg)))
16+
sys.stderr.write('%s: can\'t open: %s\n' % (filename, str(msg)))
1717
return
1818
data = f.read()
1919
f.close()
2020
if data[:2] <> '/*':
21-
sys.stderr.write('%s does not begin with C comment\n' % file)
21+
sys.stderr.write('%s does not begin with C comment\n' % filename)
2222
return
2323
try:
24-
f = open(file, 'w')
24+
f = open(filename, 'w')
2525
except IOError, msg:
26-
sys.stderr.write('%s: can\'t write: %s\n' % (file, str(msg)))
26+
sys.stderr.write('%s: can\'t write: %s\n' % (filename, str(msg)))
2727
return
28-
sys.stderr.write('Processing %s ...\n' % file)
28+
sys.stderr.write('Processing %s ...\n' % filename)
2929
magic = 'Py_'
30-
for c in file:
30+
for c in filename:
3131
if ord(c)<=0x80 and c.isalnum():
3232
magic = magic + c.upper()
3333
else: magic = magic + '_'

Tools/scripts/fixps.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@
88

99

1010
def main():
11-
for file in sys.argv[1:]:
11+
for filename in sys.argv[1:]:
1212
try:
13-
f = open(file, 'r')
13+
f = open(filename, 'r')
1414
except IOError, msg:
15-
print file, ': can\'t open :', msg
15+
print filename, ': can\'t open :', msg
1616
continue
1717
line = f.readline()
1818
if not re.match('^#! */usr/local/bin/python', line):
19-
print file, ': not a /usr/local/bin/python script'
19+
print filename, ': not a /usr/local/bin/python script'
2020
f.close()
2121
continue
2222
rest = f.read()
2323
f.close()
2424
line = re.sub('/usr/local/bin/python',
2525
'/usr/bin/env python', line)
26-
print file, ':', `line`
27-
f = open(file, "w")
26+
print filename, ':', `line`
27+
f = open(filename, "w")
2828
f.write(line)
2929
f.write(rest)
3030
f.close()

Tools/scripts/ftpmirror.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ def makedir(pathname):
384384
# rval() but is still somewhat readable (i.e. not a single long line).
385385
# Also creates a backup file.
386386
def writedict(dict, filename):
387-
dir, file = os.path.split(filename)
388-
tempname = os.path.join(dir, '@' + file)
389-
backup = os.path.join(dir, file + '~')
387+
dir, fname = os.path.split(filename)
388+
tempname = os.path.join(dir, '@' + fname)
389+
backup = os.path.join(dir, fname + '~')
390390
try:
391391
os.unlink(backup)
392392
except os.error:

Tools/scripts/ifdef.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def main():
4242
undefs.append(a)
4343
if not args:
4444
args = ['-']
45-
for file in args:
46-
if file == '-':
45+
for filename in args:
46+
if filename == '-':
4747
process(sys.stdin, sys.stdout)
4848
else:
49-
f = open(file, 'r')
49+
f = open(filename, 'r')
5050
process(f, sys.stdout)
5151
f.close()
5252

Tools/scripts/mkreal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def mkrealdir(name):
3838
os.chmod(name, mode)
3939
linkto = join(os.pardir, linkto)
4040
#
41-
for file in files:
42-
if file not in (os.curdir, os.pardir):
43-
os.symlink(join(linkto, file), join(name, file))
41+
for filename in files:
42+
if filename not in (os.curdir, os.pardir):
43+
os.symlink(join(linkto, filename), join(name, filename))
4444

4545
def main():
4646
sys.stdout = sys.stderr

0 commit comments

Comments
 (0)