Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4a623e

Browse files
committed
Add command line flags to just list the files that contain the
offending lines or to include line numbers in the output.
1 parent c8c40ff commit c4a623e

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Doc/tools/findmodrefs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# -*- Python -*-
33

44
import fileinput
5+
import getopt
56
import glob
67
import os
78
import re
@@ -15,7 +16,15 @@ module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}")
1516

1617
def main():
1718
try:
18-
files = sys.argv[1:]
19+
just_list = 0
20+
print_lineno = 0
21+
opts, args = getopt.getopt(sys.argv[1:], "ln", ["list", "number"])
22+
for opt, arg in opts:
23+
if opt in ("-l", "--list"):
24+
just_list = 1
25+
elif opt in ("-n", "--number"):
26+
print_lineno = 1
27+
files = args
1928
if not files:
2029
files = glob.glob("*.tex")
2130
files.sort()
@@ -36,7 +45,16 @@ def main():
3645
if m:
3746
name = m.group(1)
3847
if name != modulename:
39-
print "%s:%s" % (fileinput.filename(), line[:-1])
48+
filename = fileinput.filename()
49+
if just_list:
50+
print filename
51+
fileinput.nextfile()
52+
modulename = None
53+
elif print_lineno:
54+
print "%s(%d):%s" \
55+
% (filename, fileinput.filelineno(), line[:-1])
56+
else:
57+
print "%s:%s" % (filename, line[:-1])
4058
except KeyboardInterrupt:
4159
sys.exit(1)
4260

0 commit comments

Comments
 (0)