diff options
author | Fred Drake <fdrake@acm.org> | 1999-04-22 20:32:21 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-04-22 20:32:21 (GMT) |
commit | c4a623ebdc47a6da343837bf274070b5820933e4 (patch) | |
tree | ff24aca0e847cde93688bcec2b1dd6e50ea8e8b9 /Doc/tools/findmodrefs | |
parent | c8c40ff699140542bc9bbcd80d483c3154141392 (diff) | |
download | cpython-c4a623ebdc47a6da343837bf274070b5820933e4.zip cpython-c4a623ebdc47a6da343837bf274070b5820933e4.tar.gz cpython-c4a623ebdc47a6da343837bf274070b5820933e4.tar.bz2 |
Add command line flags to just list the files that contain the
offending lines or to include line numbers in the output.
Diffstat (limited to 'Doc/tools/findmodrefs')
-rwxr-xr-x | Doc/tools/findmodrefs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Doc/tools/findmodrefs b/Doc/tools/findmodrefs index c055686..8c5f93f 100755 --- a/Doc/tools/findmodrefs +++ b/Doc/tools/findmodrefs @@ -2,6 +2,7 @@ # -*- Python -*- import fileinput +import getopt import glob import os import re @@ -15,7 +16,15 @@ module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}") def main(): try: - files = sys.argv[1:] + just_list = 0 + print_lineno = 0 + opts, args = getopt.getopt(sys.argv[1:], "ln", ["list", "number"]) + for opt, arg in opts: + if opt in ("-l", "--list"): + just_list = 1 + elif opt in ("-n", "--number"): + print_lineno = 1 + files = args if not files: files = glob.glob("*.tex") files.sort() @@ -36,7 +45,16 @@ def main(): if m: name = m.group(1) if name != modulename: - print "%s:%s" % (fileinput.filename(), line[:-1]) + filename = fileinput.filename() + if just_list: + print filename + fileinput.nextfile() + modulename = None + elif print_lineno: + print "%s(%d):%s" \ + % (filename, fileinput.filelineno(), line[:-1]) + else: + print "%s:%s" % (filename, line[:-1]) except KeyboardInterrupt: sys.exit(1) |