]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add command line flags to just list the files that contain the
authorFred Drake <fdrake@acm.org>
Thu, 22 Apr 1999 20:32:21 +0000 (20:32 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 22 Apr 1999 20:32:21 +0000 (20:32 +0000)
offending lines or to include line numbers in the output.

Doc/tools/findmodrefs

index c0556863f24dc215ce3cbb0bbc53d1a6fe816139..8c5f93fb6e2d21110eca0d4c10b80182d30fda6e 100755 (executable)
@@ -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)