]> granicus.if.org Git - python/commitdiff
process(): New function that contains the "orchestration" of the
authorFred Drake <fdrake@acm.org>
Wed, 3 Mar 1999 19:25:56 +0000 (19:25 +0000)
committerFred Drake <fdrake@acm.org>
Wed, 3 Mar 1999 19:25:56 +0000 (19:25 +0000)
    actual work.

main():  Just handle the command line and filename determination,
 calling process() to do the work.

These changes make this more import-friendly.

Doc/tools/toc2bkm.py

index ca7064be927733f2a826c3e6be929dea6465bf00..c2edea3527060981b8ae0ba455fae1dc6ead0725 100755 (executable)
@@ -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__":