mirror of
https://github.com/python/cpython.git
synced 2025-11-18 01:57:37 +00:00
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.
This commit is contained in:
parent
aa99a5071e
commit
7c8754fafb
1 changed files with 6 additions and 2 deletions
|
|
@ -120,6 +120,11 @@ def write_toc_entry(entry, fp, layer):
|
||||||
write_toc_entry(entry, fp, layer + 1)
|
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():
|
def main():
|
||||||
bigpart = None
|
bigpart = None
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "c:")
|
opts, args = getopt.getopt(sys.argv[1:], "c:")
|
||||||
|
|
@ -131,8 +136,7 @@ def main():
|
||||||
for filename in args:
|
for filename in args:
|
||||||
base, ext = os.path.splitext(filename)
|
base, ext = os.path.splitext(filename)
|
||||||
ext = ext or ".toc"
|
ext = ext or ".toc"
|
||||||
toc = parse_toc(open(base + ext), bigpart)
|
process(base + ext, base + ".bkm", bigpart)
|
||||||
write_toc(toc, open(base + ".bkm", "w"))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue