diff options
author | Fred Drake <fdrake@acm.org> | 1999-03-03 19:25:56 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-03-03 19:25:56 (GMT) |
commit | 7c8754fafb9de59d7c33bbb69941c41340ab2f1e (patch) | |
tree | cef41709b2594b3b41589b6dcae8886bdfaddafa /Doc/tools/toc2bkm.py | |
parent | aa99a5071e87943e8a2749ffdc43fe83b25c704c (diff) | |
download | cpython-7c8754fafb9de59d7c33bbb69941c41340ab2f1e.zip cpython-7c8754fafb9de59d7c33bbb69941c41340ab2f1e.tar.gz cpython-7c8754fafb9de59d7c33bbb69941c41340ab2f1e.tar.bz2 |
process(): New function that contains the "orchestration" of the
actual work.
main(): Just handle the command line and filename determination,
calling process() to do the work.
These changes make this more import-friendly.
Diffstat (limited to 'Doc/tools/toc2bkm.py')
-rwxr-xr-x | Doc/tools/toc2bkm.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Doc/tools/toc2bkm.py b/Doc/tools/toc2bkm.py index ca7064b..c2edea3 100755 --- a/Doc/tools/toc2bkm.py +++ b/Doc/tools/toc2bkm.py @@ -120,6 +120,11 @@ def write_toc_entry(entry, fp, layer): write_toc_entry(entry, fp, layer + 1) +def process(ifn, ofn, bigpart=None): + toc = parse_toc(open(ifn), bigpart) + write_toc(toc, open(ofn, "w")) + + def main(): bigpart = None opts, args = getopt.getopt(sys.argv[1:], "c:") @@ -131,8 +136,7 @@ def main(): for filename in args: base, ext = os.path.splitext(filename) ext = ext or ".toc" - toc = parse_toc(open(base + ext), bigpart) - write_toc(toc, open(base + ".bkm", "w")) + process(base + ext, base + ".bkm", bigpart) if __name__ == "__main__": |