Fred Drake | 693a2c6 | 1999-04-22 13:08:09 +0000 | [diff] [blame^] | 1 | #! /usr/bin/env python |
| 2 | # -*- Python -*- |
| 3 | |
| 4 | import fileinput |
| 5 | import glob |
| 6 | import os |
| 7 | import re |
| 8 | import sys |
| 9 | |
| 10 | |
| 11 | declare_rx = re.compile( |
| 12 | r"\\declaremodule(?:\[[a-zA-Z0-9]*\]*)?{[a-zA-Z_0-9]+}{([a-zA-Z_0-9]+)}") |
| 13 | |
| 14 | module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}") |
| 15 | |
| 16 | def main(): |
| 17 | try: |
| 18 | files = sys.argv[1:] |
| 19 | if not files: |
| 20 | files = glob.glob("*.tex") |
| 21 | files.sort() |
| 22 | modulename = None |
| 23 | for line in fileinput.input(files): |
| 24 | if line[:9] == r"\section{": |
| 25 | modulename = None |
| 26 | continue |
| 27 | if line[:16] == r"\modulesynopsys{": |
| 28 | continue |
| 29 | m = declare_rx.match(line) |
| 30 | if m: |
| 31 | modulename = m.group(1) |
| 32 | continue |
| 33 | if not modulename: |
| 34 | continue |
| 35 | m = module_rx.search(line) |
| 36 | if m: |
| 37 | name = m.group(1) |
| 38 | if name != modulename: |
| 39 | print "%s:%s" % (fileinput.filename(), line[:-1]) |
| 40 | except KeyboardInterrupt: |
| 41 | sys.exit(1) |
| 42 | |
| 43 | |
| 44 | if __name__ == "__main__": |
| 45 | main() |