From ac6df95d07aa3951f8bfc6febce132e09850db73 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 13 May 2003 18:14:25 +0000 Subject: Fix use of 'file' as a variable name. (I've tested the fixes, but please proofread anyway.) --- Tools/scripts/byteyears.py | 12 ++++++------ Tools/scripts/dutree.py | 4 ++-- Tools/scripts/eptags.py | 16 ++++++++-------- Tools/scripts/finddiv.py | 16 ++++++++-------- Tools/scripts/fixdiv.py | 16 ++++++++-------- Tools/scripts/fixheader.py | 20 ++++++++++---------- Tools/scripts/fixps.py | 12 ++++++------ Tools/scripts/ftpmirror.py | 6 +++--- Tools/scripts/ifdef.py | 6 +++--- Tools/scripts/mkreal.py | 6 +++--- Tools/scripts/objgraph.py | 36 ++++++++++++++++++------------------ Tools/scripts/pindent.py | 4 ++-- Tools/scripts/ptags.py | 15 ++++++++------- Tools/scripts/suff.py | 14 +++++++------- Tools/scripts/untabify.py | 18 +++++++++--------- Tools/scripts/which.py | 14 +++++++------- 16 files changed, 108 insertions(+), 107 deletions(-) diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py index 2b0f9b2..9c2a974 100755 --- a/Tools/scripts/byteyears.py +++ b/Tools/scripts/byteyears.py @@ -34,15 +34,15 @@ status = 0 # Exit status, set to 1 on errors # Compute max file name length maxlen = 1 -for file in sys.argv[1:]: - if len(file) > maxlen: maxlen = len(file) +for filename in sys.argv[1:]: + maxlen = max(maxlen, len(filename)) # Process each argument in turn -for file in sys.argv[1:]: +for filename in sys.argv[1:]: try: - st = statfunc(file) + st = statfunc(filename) except os.error, msg: - sys.stderr.write('can\'t stat ' + `file` + ': ' + `msg` + '\n') + sys.stderr.write('can\'t stat ' + `filename` + ': ' + `msg` + '\n') status = 1 st = () if st: @@ -50,7 +50,7 @@ for file in sys.argv[1:]: size = st[ST_SIZE] age = now - anytime byteyears = float(size) * float(age) / secs_per_year - print file.ljust(maxlen), + print filename.ljust(maxlen), print repr(int(byteyears)).rjust(8) sys.exit(status) diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py index 35b3916..857a5cc 100755 --- a/Tools/scripts/dutree.py +++ b/Tools/scripts/dutree.py @@ -11,8 +11,8 @@ def main(): while line[i] in '0123456789': i = i+1 size = eval(line[:i]) while line[i] in ' \t': i = i+1 - file = line[i:-1] - comps = file.split('/') + filename = line[i:-1] + comps = filename.split('/') if comps[0] == '': comps[0] = '/' if comps[len(comps)-1] == '': del comps[len(comps)-1] total, d = store(size, comps, total, d) diff --git a/Tools/scripts/eptags.py b/Tools/scripts/eptags.py index dca875b..8d35dfb 100755 --- a/Tools/scripts/eptags.py +++ b/Tools/scripts/eptags.py @@ -21,12 +21,12 @@ import sys,re expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]' matcher = re.compile(expr) -def treat_file(file, outfp): - """Append tags found in file named 'file' to the open file 'outfp'""" +def treat_file(filename, outfp): + """Append tags found in file named 'filename' to the open file 'outfp'""" try: - fp = open(file, 'r') + fp = open(filename, 'r') except: - sys.stderr.write('Cannot open %s\n'%file) + sys.stderr.write('Cannot open %s\n'%filename) return charno = 0 lineno = 0 @@ -39,18 +39,18 @@ def treat_file(file, outfp): lineno = lineno + 1 m = matcher.search(line) if m: - tag = m.group(0) + '\177%d,%d\n'%(lineno,charno) + tag = m.group(0) + '\177%d,%d\n' % (lineno, charno) tags.append(tag) size = size + len(tag) charno = charno + len(line) - outfp.write('\f\n%s,%d\n'%(file,size)) + outfp.write('\f\n%s,%d\n' % (filename,size)) for tag in tags: outfp.write(tag) def main(): outfp = open('TAGS', 'w') - for file in sys.argv[1:]: - treat_file(file, outfp) + for filename in sys.argv[1:]: + treat_file(filename, outfp) if __name__=="__main__": main() diff --git a/Tools/scripts/finddiv.py b/Tools/scripts/finddiv.py index 47b6f12..97f6331 100755 --- a/Tools/scripts/finddiv.py +++ b/Tools/scripts/finddiv.py @@ -37,8 +37,8 @@ def main(): if o == "-l": listnames = 1 exit = None - for file in args: - x = process(file, listnames) + for filename in args: + x = process(filename, listnames) exit = exit or x return exit @@ -47,11 +47,11 @@ def usage(msg): sys.stderr.write("Usage: %s [-l] file ...\n" % sys.argv[0]) sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) -def process(file, listnames): - if os.path.isdir(file): - return processdir(file, listnames) +def process(filename, listnames): + if os.path.isdir(filename): + return processdir(filename, listnames) try: - fp = open(file) + fp = open(filename) except IOError, msg: sys.stderr.write("Can't open: %s\n" % msg) return 1 @@ -60,11 +60,11 @@ def process(file, listnames): for type, token, (row, col), end, line in g: if token in ("/", "/="): if listnames: - print file + print filename break if row != lastrow: lastrow = row - print "%s:%d:%s" % (file, row, line), + print "%s:%d:%s" % (filename, row, line), fp.close() def processdir(dir, listnames): diff --git a/Tools/scripts/fixdiv.py b/Tools/scripts/fixdiv.py index d05aa7c..70d5f19 100755 --- a/Tools/scripts/fixdiv.py +++ b/Tools/scripts/fixdiv.py @@ -164,8 +164,8 @@ def main(): return files.sort() exit = None - for file in files: - x = process(file, warnings[file]) + for filename in files: + x = process(filename, warnings[filename]) exit = exit or x return exit @@ -194,23 +194,23 @@ def readwarnings(warningsfile): if line.find("division") >= 0: sys.stderr.write("Warning: ignored input " + line) continue - file, lineno, what = m.groups() - list = warnings.get(file) + filename, lineno, what = m.groups() + list = warnings.get(filename) if list is None: - warnings[file] = list = [] + warnings[filename] = list = [] list.append((int(lineno), intern(what))) f.close() return warnings -def process(file, list): +def process(filename, list): print "-"*70 assert list # if this fails, readwarnings() is broken try: - fp = open(file) + fp = open(filename) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return 1 - print "Index:", file + print "Index:", filename f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do diff --git a/Tools/scripts/fixheader.py b/Tools/scripts/fixheader.py index 1f9c713..02b4f3b 100755 --- a/Tools/scripts/fixheader.py +++ b/Tools/scripts/fixheader.py @@ -6,28 +6,28 @@ import sys def main(): args = sys.argv[1:] - for file in args: - process(file) + for filename in args: + process(filename) -def process(file): +def process(filename): try: - f = open(file, 'r') + f = open(filename, 'r') except IOError, msg: - sys.stderr.write('%s: can\'t open: %s\n' % (file, str(msg))) + sys.stderr.write('%s: can\'t open: %s\n' % (filename, str(msg))) return data = f.read() f.close() if data[:2] <> '/*': - sys.stderr.write('%s does not begin with C comment\n' % file) + sys.stderr.write('%s does not begin with C comment\n' % filename) return try: - f = open(file, 'w') + f = open(filename, 'w') except IOError, msg: - sys.stderr.write('%s: can\'t write: %s\n' % (file, str(msg))) + sys.stderr.write('%s: can\'t write: %s\n' % (filename, str(msg))) return - sys.stderr.write('Processing %s ...\n' % file) + sys.stderr.write('Processing %s ...\n' % filename) magic = 'Py_' - for c in file: + for c in filename: if ord(c)<=0x80 and c.isalnum(): magic = magic + c.upper() else: magic = magic + '_' diff --git a/Tools/scripts/fixps.py b/Tools/scripts/fixps.py index 1e6e114..e406571 100755 --- a/Tools/scripts/fixps.py +++ b/Tools/scripts/fixps.py @@ -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() diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py index 2e3b215..41607b0 100755 --- a/Tools/scripts/ftpmirror.py +++ b/Tools/scripts/ftpmirror.py @@ -384,9 +384,9 @@ def makedir(pathname): # rval() but is still somewhat readable (i.e. not a single long line). # Also creates a backup file. def writedict(dict, filename): - dir, file = os.path.split(filename) - tempname = os.path.join(dir, '@' + file) - backup = os.path.join(dir, file + '~') + dir, fname = os.path.split(filename) + tempname = os.path.join(dir, '@' + fname) + backup = os.path.join(dir, fname + '~') try: os.unlink(backup) except os.error: diff --git a/Tools/scripts/ifdef.py b/Tools/scripts/ifdef.py index c0c1459..15777f4 100755 --- a/Tools/scripts/ifdef.py +++ b/Tools/scripts/ifdef.py @@ -42,11 +42,11 @@ def main(): undefs.append(a) if not args: args = ['-'] - for file in args: - if file == '-': + for filename in args: + if filename == '-': process(sys.stdin, sys.stdout) else: - f = open(file, 'r') + f = open(filename, 'r') process(f, sys.stdout) f.close() diff --git a/Tools/scripts/mkreal.py b/Tools/scripts/mkreal.py index eda01a8..a890ac7 100755 --- a/Tools/scripts/mkreal.py +++ b/Tools/scripts/mkreal.py @@ -38,9 +38,9 @@ def mkrealdir(name): os.chmod(name, mode) linkto = join(os.pardir, linkto) # - for file in files: - if file not in (os.curdir, os.pardir): - os.symlink(join(linkto, file), join(name, file)) + for filename in files: + if filename not in (os.curdir, os.pardir): + os.symlink(join(linkto, filename), join(name, filename)) def main(): sys.stdout = sys.stderr diff --git a/Tools/scripts/objgraph.py b/Tools/scripts/objgraph.py index 3e040b9..c48a425 100755 --- a/Tools/scripts/objgraph.py +++ b/Tools/scripts/objgraph.py @@ -63,9 +63,9 @@ undef2file = {} # Read one input file and merge the data into the tables. # Argument is an open file. # -def readinput(file): +def readinput(fp): while 1: - s = file.readline() + s = fp.readline() if not s: break # If you get any output from this line, @@ -88,9 +88,9 @@ def readinput(file): def printcallee(): flist = file2undef.keys() flist.sort() - for file in flist: - print file + ':' - elist = file2undef[file] + for filename in flist: + print filename + ':' + elist = file2undef[filename] elist.sort() for ext in elist: if len(ext) >= 8: @@ -107,38 +107,38 @@ def printcallee(): def printcaller(): files = file2def.keys() files.sort() - for file in files: + for filename in files: callers = [] - for label in file2def[file]: + for label in file2def[filename]: if undef2file.has_key(label): callers = callers + undef2file[label] if callers: callers.sort() - print file + ':' + print filename + ':' lastfn = '' for fn in callers: if fn <> lastfn: print '\t' + fn lastfn = fn else: - print file + ': unused' + print filename + ': unused' -# Print undefine names and where they are used. +# Print undefined names and where they are used. # def printundef(): undefs = {} - for file in file2undef.keys(): - for ext in file2undef[file]: + for filename in file2undef.keys(): + for ext in file2undef[filename]: if not def2file.has_key(ext): - store(undefs, ext, file) + store(undefs, ext, filename) elist = undefs.keys() elist.sort() for ext in elist: print ext + ':' flist = undefs[ext] flist.sort() - for file in flist: - print '\t' + file + for filename in flist: + print '\t' + filename # Print warning messages about names defined in more than one file. # @@ -181,11 +181,11 @@ def main(): optu = optc = optd = 1 if not args: args = ['-'] - for file in args: - if file == '-': + for filename in args: + if filename == '-': readinput(sys.stdin) else: - readinput(open(file, 'r')) + readinput(open(filename, 'r')) # warndups() # diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py index 75175dc..39cdcc8 100755 --- a/Tools/scripts/pindent.py +++ b/Tools/scripts/pindent.py @@ -531,8 +531,8 @@ def test(): action(sys.stdin, sys.stdout, stepsize, tabsize, expandtabs) else: action = eval(action + '_file') - for file in args: - action(file, stepsize, tabsize, expandtabs) + for filename in args: + action(filename, stepsize, tabsize, expandtabs) # end for # end if # end def test diff --git a/Tools/scripts/ptags.py b/Tools/scripts/ptags.py index ea8eb3f..de6e901 100755 --- a/Tools/scripts/ptags.py +++ b/Tools/scripts/ptags.py @@ -16,7 +16,8 @@ tags = [] # Modified global variable! def main(): args = sys.argv[1:] - for file in args: treat_file(file) + for filename in args: + treat_file(filename) if tags: fp = open('tags', 'w') tags.sort() @@ -26,16 +27,16 @@ def main(): expr = '^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*[:\(]' matcher = re.compile(expr) -def treat_file(file): +def treat_file(filename): try: - fp = open(file, 'r') + fp = open(filename, 'r') except: - sys.stderr.write('Cannot open %s\n' % file) + sys.stderr.write('Cannot open %s\n' % filename) return - base = os.path.basename(file) + base = os.path.basename(filename) if base[-3:] == '.py': base = base[:-3] - s = base + '\t' + file + '\t' + '1\n' + s = base + '\t' + filename + '\t' + '1\n' tags.append(s) while 1: line = fp.readline() @@ -45,7 +46,7 @@ def treat_file(file): if m: content = m.group(0) name = m.group(2) - s = name + '\t' + file + '\t/^' + content + '/\n' + s = name + '\t' + filename + '\t/^' + content + '/\n' tags.append(s) main() diff --git a/Tools/scripts/suff.py b/Tools/scripts/suff.py index e085cd0..ee7499f 100755 --- a/Tools/scripts/suff.py +++ b/Tools/scripts/suff.py @@ -9,21 +9,21 @@ import sys def main(): files = sys.argv[1:] suffixes = {} - for file in files: - suff = getsuffix(file) + for filename in files: + suff = getsuffix(filename) if not suffixes.has_key(suff): suffixes[suff] = [] - suffixes[suff].append(file) + suffixes[suff].append(filename) keys = suffixes.keys() keys.sort() for suff in keys: print `suff`, len(suffixes[suff]) -def getsuffix(file): +def getsuffix(filename): suff = '' - for i in range(len(file)): - if file[i] == '.': - suff = file[i:] + for i in range(len(filename)): + if filename[i] == '.': + suff = filename[i:] return suff main() diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py index 5eaf50e..17e9166 100755 --- a/Tools/scripts/untabify.py +++ b/Tools/scripts/untabify.py @@ -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() diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py index 19e3203..99dc355 100755 --- a/Tools/scripts/which.py +++ b/Tools/scripts/which.py @@ -25,29 +25,29 @@ if sys.argv[1:] and sys.argv[1][:2] == '-l': for prog in sys.argv[1:]: ident = () for dir in pathlist: - file = os.path.join(dir, prog) + filename = os.path.join(dir, prog) try: - st = os.stat(file) + st = os.stat(filename) except os.error: continue if not S_ISREG(st[ST_MODE]): - msg(file + ': not a disk file') + msg(filename + ': not a disk file') else: mode = S_IMODE(st[ST_MODE]) if mode & 0111: if not ident: - print file + print filename ident = st[:3] else: if st[:3] == ident: s = 'same as: ' else: s = 'also: ' - msg(s + file) + msg(s + filename) else: - msg(file + ': not executable') + msg(filename + ': not executable') if longlist: - sts = os.system('ls ' + longlist + ' ' + file) + sts = os.system('ls ' + longlist + ' ' + filename) if sts: msg('"ls -l" exit status: ' + `sts`) if not ident: msg(prog + ': not found') -- cgit v0.12