]> granicus.if.org Git - python/commitdiff
Fix use of 'file' as a variable name.
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 13 May 2003 18:14:25 +0000 (18:14 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 13 May 2003 18:14:25 +0000 (18:14 +0000)
    (I've tested the fixes, but please proofread anyway.)

16 files changed:
Tools/scripts/byteyears.py
Tools/scripts/dutree.py
Tools/scripts/eptags.py
Tools/scripts/finddiv.py
Tools/scripts/fixdiv.py
Tools/scripts/fixheader.py
Tools/scripts/fixps.py
Tools/scripts/ftpmirror.py
Tools/scripts/ifdef.py
Tools/scripts/mkreal.py
Tools/scripts/objgraph.py
Tools/scripts/pindent.py
Tools/scripts/ptags.py
Tools/scripts/suff.py
Tools/scripts/untabify.py
Tools/scripts/which.py

index 2b0f9b2bf3280d606991dad590f75f1dc1b7c63f..9c2a974643c03ba12950e7d90bdea8a6a5f7bbe7 100755 (executable)
@@ -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)
index 35b39164921d94a3106ed3edfc2ae0e3d1f63eda..857a5cc4fcff14bcf947b7c339e3117bae8a864e 100755 (executable)
@@ -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)
index dca875bcfe475247a4b612fe50421231238b8189..8d35dfb31e1f0440396f76673bf1f6e7095a5db0 100755 (executable)
@@ -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()
index 47b6f12e749fd6abc3a1a7a2059533a2e957d33d..97f63316c774acfbb5372dfbcccc1344c3b5217b 100755 (executable)
@@ -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):
index d05aa7ca53262f0cd8d0cd6491e53ad567350ba9..70d5f1933528a0fe636fd318c084a85af84aefde 100755 (executable)
@@ -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
index 1f9c71310ac7886d0b99f05b0ccff1a80aff5f71..02b4f3b0d1450eee2c76f510b29713f5b9ea986a 100755 (executable)
@@ -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 + '_'
index 1e6e114af3826955dd4bfff2a6fd4409878705b6..e406571e7225c9c3a0dac48253bdc5435bfe1ab1 100755 (executable)
@@ -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()
index 2e3b215835c6cad1b6feb0d6c437975a97df3cb5..41607b0b7e27e12dd0fc64d0db6281bad49c7a1e 100755 (executable)
@@ -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:
index c0c14595733a1deb95ab3404788605acd8966416..15777f4392e2172f4a38b4b49f4dfb214a346d47 100755 (executable)
@@ -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()
 
index eda01a8bb91a7d9f41f4ae2aeaa679ebad5da7f0..a890ac727010275043f169c0bbe4596d72d48c83 100755 (executable)
@@ -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
index 3e040b9879f7a71fbbae9b7828396c692feb411b..c48a425d848a0d4ff6354e52fa1ffca68780c7b2 100755 (executable)
@@ -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()
     #
index 75175dc83aee9c6f9ea9b93d46b39234e4ffd8fc..39cdcc8b469dcaf0bb06208d0edd06a279f93319 100755 (executable)
@@ -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
index ea8eb3f1c2bf2dbf392197156719a6386c7952c0..de6e90140ad1b9654b84843e970a4208289454e0 100755 (executable)
@@ -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()
index e085cd0df916b3c7b996ef126c1cf3190073ea2c..ee7499f5e47f88ed81e8c5828a0a4204152cc8b1 100755 (executable)
@@ -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()
index 5eaf50ea65d6462a24bb039e07e25cc71af96aa9..17e9166690138c376133a8f5b2873ecfa4660ad7 100755 (executable)
@@ -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()
index 19e3203ff5f662b9671a8f83665918bf073f0bf0..99dc35544c6aeba640930c6c7caabf88097a5c5c 100755 (executable)
@@ -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')