| 1 | #! /usr/bin/env python
|
|---|
| 2 | # -*- Python -*-
|
|---|
| 3 |
|
|---|
| 4 | import fileinput
|
|---|
| 5 | import getopt
|
|---|
| 6 | import glob
|
|---|
| 7 | import os
|
|---|
| 8 | import re
|
|---|
| 9 | import sys
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 | declare_rx = re.compile(
|
|---|
| 13 | r"\\declaremodule(?:\[[a-zA-Z0-9]*\]*)?{[a-zA-Z_0-9]+}{([a-zA-Z_0-9]+)}")
|
|---|
| 14 |
|
|---|
| 15 | module_rx = re.compile(r"\\module{([a-zA-Z_0-9]+)}")
|
|---|
| 16 |
|
|---|
| 17 | def 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
|
|---|
|
|---|