| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,23 +34,23 @@ | |||
| 34 | 34 | ||
| 35 | 35 | # Compute max file name length | |
| 36 | 36 | 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)) | ||
| 39 | 39 | ||
| 40 | 40 | # Process each argument in turn | |
| 41 | - for file in sys.argv[1:]: | ||
| 41 | + for filename in sys.argv[1:]: | ||
| 42 | 42 | try: | |
| 43 | - st = statfunc(file) | ||
| 43 | + st = statfunc(filename) | ||
| 44 | 44 | except os.error, msg: | |
| 45 | - sys.stderr.write('can\'t stat ' + `file` + ': ' + `msg` + '\n') | ||
| 45 | + sys.stderr.write('can\'t stat ' + `filename` + ': ' + `msg` + '\n') | ||
| 46 | 46 | status = 1 | |
| 47 | 47 | st = () | |
| 48 | 48 | if st: | |
| 49 | 49 | anytime = st[itime] | |
| 50 | 50 | size = st[ST_SIZE] | |
| 51 | 51 | age = now - anytime | |
| 52 | 52 | byteyears = float(size) * float(age) / secs_per_year | |
| 53 | - print file.ljust(maxlen), | ||
| 53 | + print filename.ljust(maxlen), | ||
| 54 | 54 | print repr(int(byteyears)).rjust(8) | |
| 55 | 55 | ||
| 56 | 56 | sys.exit(status) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,8 +11,8 @@ def main(): | |||
| 11 | 11 | while line[i] in '0123456789': i = i+1 | |
| 12 | 12 | size = eval(line[:i]) | |
| 13 | 13 | 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('/') | ||
| 16 | 16 | if comps[0] == '': comps[0] = '/' | |
| 17 | 17 | if comps[len(comps)-1] == '': del comps[len(comps)-1] | |
| 18 | 18 | total, d = store(size, comps, total, d) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,12 +21,12 @@ | |||
| 21 | 21 | expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]' | |
| 22 | 22 | matcher = re.compile(expr) | |
| 23 | 23 | ||
| 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'""" | ||
| 26 | 26 | try: | |
| 27 | - fp = open(file, 'r') | ||
| 27 | + fp = open(filename, 'r') | ||
| 28 | 28 | except: | |
| 29 | - sys.stderr.write('Cannot open %s\n'%file) | ||
| 29 | + sys.stderr.write('Cannot open %s\n'%filename) | ||
| 30 | 30 | return | |
| 31 | 31 | charno = 0 | |
| 32 | 32 | lineno = 0 | |
@@ -39,18 +39,18 @@ def treat_file(file, outfp): | |||
| 39 | 39 | lineno = lineno + 1 | |
| 40 | 40 | m = matcher.search(line) | |
| 41 | 41 | if m: | |
| 42 | - tag = m.group(0) + '\177%d,%d\n'%(lineno,charno) | ||
| 42 | + tag = m.group(0) + '\177%d,%d\n' % (lineno, charno) | ||
| 43 | 43 | tags.append(tag) | |
| 44 | 44 | size = size + len(tag) | |
| 45 | 45 | charno = charno + len(line) | |
| 46 | - outfp.write('\f\n%s,%d\n'%(file,size)) | ||
| 46 | + outfp.write('\f\n%s,%d\n' % (filename,size)) | ||
| 47 | 47 | for tag in tags: | |
| 48 | 48 | outfp.write(tag) | |
| 49 | 49 | ||
| 50 | 50 | def main(): | |
| 51 | 51 | 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) | ||
| 54 | 54 | ||
| 55 | 55 | if __name__=="__main__": | |
| 56 | 56 | main() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,8 +37,8 @@ def main(): | |||
| 37 | 37 | if o == "-l": | |
| 38 | 38 | listnames = 1 | |
| 39 | 39 | exit = None | |
| 40 | - for file in args: | ||
| 41 | - x = process(file, listnames) | ||
| 40 | + for filename in args: | ||
| 41 | + x = process(filename, listnames) | ||
| 42 | 42 | exit = exit or x | |
| 43 | 43 | return exit | |
| 44 | 44 | ||
@@ -47,11 +47,11 @@ def usage(msg): | |||
| 47 | 47 | sys.stderr.write("Usage: %s [-l] file ...\n" % sys.argv[0]) | |
| 48 | 48 | sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) | |
| 49 | 49 | ||
| 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) | ||
| 53 | 53 | try: | |
| 54 | - fp = open(file) | ||
| 54 | + fp = open(filename) | ||
| 55 | 55 | except IOError, msg: | |
| 56 | 56 | sys.stderr.write("Can't open: %s\n" % msg) | |
| 57 | 57 | return 1 | |
@@ -60,11 +60,11 @@ def process(file, listnames): | |||
| 60 | 60 | for type, token, (row, col), end, line in g: | |
| 61 | 61 | if token in ("/", "/="): | |
| 62 | 62 | if listnames: | |
| 63 | - print file | ||
| 63 | + print filename | ||
| 64 | 64 | break | |
| 65 | 65 | if row != lastrow: | |
| 66 | 66 | lastrow = row | |
| 67 | - print "%s:%d:%s" % (file, row, line), | ||
| 67 | + print "%s:%d:%s" % (filename, row, line), | ||
| 68 | 68 | fp.close() | |
| 69 | 69 | ||
| 70 | 70 | def processdir(dir, listnames): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,8 +164,8 @@ def main(): | |||
| 164 | 164 | return | |
| 165 | 165 | files.sort() | |
| 166 | 166 | exit = None | |
| 167 | - for file in files: | ||
| 168 | - x = process(file, warnings[file]) | ||
| 167 | + for filename in files: | ||
| 168 | + x = process(filename, warnings[filename]) | ||
| 169 | 169 | exit = exit or x | |
| 170 | 170 | return exit | |
| 171 | 171 | ||
@@ -194,23 +194,23 @@ def readwarnings(warningsfile): | |||
| 194 | 194 | if line.find("division") >= 0: | |
| 195 | 195 | sys.stderr.write("Warning: ignored input " + line) | |
| 196 | 196 | continue | |
| 197 | - file, lineno, what = m.groups() | ||
| 198 | - list = warnings.get(file) | ||
| 197 | + filename, lineno, what = m.groups() | ||
| 198 | + list = warnings.get(filename) | ||
| 199 | 199 | if list is None: | |
| 200 | - warnings[file] = list = [] | ||
| 200 | + warnings[filename] = list = [] | ||
| 201 | 201 | list.append((int(lineno), intern(what))) | |
| 202 | 202 | f.close() | |
| 203 | 203 | return warnings | |
| 204 | 204 | ||
| 205 | - def process(file, list): | ||
| 205 | + def process(filename, list): | ||
| 206 | 206 | print "-"*70 | |
| 207 | 207 | assert list # if this fails, readwarnings() is broken | |
| 208 | 208 | try: | |
| 209 | - fp = open(file) | ||
| 209 | + fp = open(filename) | ||
| 210 | 210 | except IOError, msg: | |
| 211 | 211 | sys.stderr.write("can't open: %s\n" % msg) | |
| 212 | 212 | return 1 | |
| 213 | - print "Index:", file | ||
| 213 | + print "Index:", filename | ||
| 214 | 214 | f = FileContext(fp) | |
| 215 | 215 | list.sort() | |
| 216 | 216 | index = 0 # list[:index] has been processed, list[index:] is still to do | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,28 +6,28 @@ | |||
| 6 | 6 | ||
| 7 | 7 | def main(): | |
| 8 | 8 | args = sys.argv[1:] | |
| 9 | - for file in args: | ||
| 10 | - process(file) | ||
| 9 | + for filename in args: | ||
| 10 | + process(filename) | ||
| 11 | 11 | ||
| 12 | - def process(file): | ||
| 12 | + def process(filename): | ||
| 13 | 13 | try: | |
| 14 | - f = open(file, 'r') | ||
| 14 | + f = open(filename, 'r') | ||
| 15 | 15 | 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))) | ||
| 17 | 17 | return | |
| 18 | 18 | data = f.read() | |
| 19 | 19 | f.close() | |
| 20 | 20 | 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) | ||
| 22 | 22 | return | |
| 23 | 23 | try: | |
| 24 | - f = open(file, 'w') | ||
| 24 | + f = open(filename, 'w') | ||
| 25 | 25 | 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))) | ||
| 27 | 27 | return | |
| 28 | - sys.stderr.write('Processing %s ...\n' % file) | ||
| 28 | + sys.stderr.write('Processing %s ...\n' % filename) | ||
| 29 | 29 | magic = 'Py_' | |
| 30 | - for c in file: | ||
| 30 | + for c in filename: | ||
| 31 | 31 | if ord(c)<=0x80 and c.isalnum(): | |
| 32 | 32 | magic = magic + c.upper() | |
| 33 | 33 | else: magic = magic + '_' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,23 +8,23 @@ | |||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | 10 | def main(): | |
| 11 | - for file in sys.argv[1:]: | ||
| 11 | + for filename in sys.argv[1:]: | ||
| 12 | 12 | try: | |
| 13 | - f = open(file, 'r') | ||
| 13 | + f = open(filename, 'r') | ||
| 14 | 14 | except IOError, msg: | |
| 15 | - print file, ': can\'t open :', msg | ||
| 15 | + print filename, ': can\'t open :', msg | ||
| 16 | 16 | continue | |
| 17 | 17 | line = f.readline() | |
| 18 | 18 | 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' | ||
| 20 | 20 | f.close() | |
| 21 | 21 | continue | |
| 22 | 22 | rest = f.read() | |
| 23 | 23 | f.close() | |
| 24 | 24 | line = re.sub('/usr/local/bin/python', | |
| 25 | 25 | '/usr/bin/env python', line) | |
| 26 | - print file, ':', `line` | ||
| 27 | - f = open(file, "w") | ||
| 26 | + print filename, ':', `line` | ||
| 27 | + f = open(filename, "w") | ||
| 28 | 28 | f.write(line) | |
| 29 | 29 | f.write(rest) | |
| 30 | 30 | f.close() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -384,9 +384,9 @@ def makedir(pathname): | |||
| 384 | 384 | # rval() but is still somewhat readable (i.e. not a single long line). | |
| 385 | 385 | # Also creates a backup file. | |
| 386 | 386 | 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 + '~') | ||
| 390 | 390 | try: | |
| 391 | 391 | os.unlink(backup) | |
| 392 | 392 | except os.error: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,11 +42,11 @@ def main(): | |||
| 42 | 42 | undefs.append(a) | |
| 43 | 43 | if not args: | |
| 44 | 44 | args = ['-'] | |
| 45 | - for file in args: | ||
| 46 | - if file == '-': | ||
| 45 | + for filename in args: | ||
| 46 | + if filename == '-': | ||
| 47 | 47 | process(sys.stdin, sys.stdout) | |
| 48 | 48 | else: | |
| 49 | - f = open(file, 'r') | ||
| 49 | + f = open(filename, 'r') | ||
| 50 | 50 | process(f, sys.stdout) | |
| 51 | 51 | f.close() | |
| 52 | 52 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,9 +38,9 @@ def mkrealdir(name): | |||
| 38 | 38 | os.chmod(name, mode) | |
| 39 | 39 | linkto = join(os.pardir, linkto) | |
| 40 | 40 | # | |
| 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)) | ||
| 44 | 44 | ||
| 45 | 45 | def main(): | |
| 46 | 46 | sys.stdout = sys.stderr | |
| Back | FazBrowse Home | New Git URL |
0 commit comments