From fa651577795a6d914eb85d5bb4e447f5e20421b0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 30 Dec 2019 13:52:08 -0800 Subject: [PATCH] When merging, start indices at 1 instead of 0. When going through the resulting merged book in sigil, it's confusing to remember that the index prefix on every file is not actually the number of the book that you're working on, especially if it's a numbered series of books. --- epubfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epubfile.py b/epubfile.py index 7434293..c53ffee 100644 --- a/epubfile.py +++ b/epubfile.py @@ -1325,6 +1325,8 @@ def merge(input_filepaths, output_filename, do_headerfile=False): rand_prefix = random_string(3, string.digits) for (index, input_filepath) in enumerate(input_filepaths): + # Number books from 1 for human sanity. + index += 1 print(f'Merging {input_filepath.absolute_path}.') prefix = f'{rand_prefix}_{index:>0{index_length}}_{{}}' input_book = Epub.open(input_filepath) @@ -1364,7 +1366,7 @@ def merge(input_filepaths, output_filename, do_headerfile=False): book.add_file(headerfile_id, headerfile_basename, content) for id in manifest_ids: - new_id = f'{rand_prefix}_{index:>0{index_length}}_{id}' + new_id = prefix.format(id) new_basename = basename_map[id] book.add_file(new_id, new_basename, input_book.read_file(id))