12
declare_rx = re.compile(
13
r"\\declaremodule(?:\[[a-zA-Z0-9]*\]*)?{[a-zA-Z_0-9]+}{([a-zA-Z_0-9]+)}")
15
module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}")
21
opts, args = getopt.getopt(sys.argv[1:], "ln", ["list", "number"])
23
if opt in ("-l", "--list"):
25
elif opt in ("-n", "--number"):
29
files = glob.glob("*.tex")
32
for line in fileinput.input(files):
33
if line[:9] == r"\section{":
36
if line[:16] == r"\modulesynopsys{":
38
m = declare_rx.match(line)
40
modulename = m.group(1)
44
m = module_rx.search(line)
47
if name != modulename:
48
filename = fileinput.filename()
55
% (filename, fileinput.filelineno(), line[:-1])
57
print "%s:%s" % (filename, line[:-1])
58
except KeyboardInterrupt:
62
if __name__ == "__main__":