Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7c8754f

Browse files
committed
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.
1 parent aa99a50 commit 7c8754f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Doc/tools/toc2bkm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ def write_toc_entry(entry, fp, layer):
120120
write_toc_entry(entry, fp, layer + 1)
121121

122122

123+
def process(ifn, ofn, bigpart=None):
124+
toc = parse_toc(open(ifn), bigpart)
125+
write_toc(toc, open(ofn, "w"))
126+
127+
123128
def main():
124129
bigpart = None
125130
opts, args = getopt.getopt(sys.argv[1:], "c:")
@@ -131,8 +136,7 @@ def main():
131136
for filename in args:
132137
base, ext = os.path.splitext(filename)
133138
ext = ext or ".toc"
134-
toc = parse_toc(open(base + ext), bigpart)
135-
write_toc(toc, open(base + ".bkm", "w"))
139+
process(base + ext, base + ".bkm", bigpart)
136140

137141

138142
if __name__ == "__main__":

0 commit comments

Comments
 (0)