source: trunk/essentials/dev-lang/python/Doc/tools/findmodrefs@ 3397

Last change on this file since 3397 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 1.8 KB
Line 
1#! /usr/bin/env python
2# -*- Python -*-
3
4import fileinput
5import getopt
6import glob
7import os
8import re
9import sys
10
11
12declare_rx = re.compile(
13 r"\\declaremodule(?:\[[a-zA-Z0-9]*\]*)?{[a-zA-Z_0-9]+}{([a-zA-Z_0-9]+)}")
14
15module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}")
16
17def main():
18 try:
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
28 if not files:
29 files = glob.glob("*.tex")
30 files.sort()
31 modulename = None
32 for line in fileinput.input(files):
33 if line[:9] == r"\section{":
34 modulename = None
35 continue
36 if line[:16] == r"\modulesynopsys{":
37 continue