From 40b3ed134083e06a1d7653bff01686863ab6a68c Mon Sep 17 00:00:00 2001 From: erin Date: Sat, 23 Dec 2023 06:07:07 +1000 Subject: [PATCH] Update variable names in navigation footer script --- scripts/inject-chapter-navigation-footer | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/inject-chapter-navigation-footer b/scripts/inject-chapter-navigation-footer index 45c9c296..77cb82e5 100644 --- a/scripts/inject-chapter-navigation-footer +++ b/scripts/inject-chapter-navigation-footer @@ -32,26 +32,26 @@ spine_titles = [se.easy_xml.EasyXmlTree(open(file_path).read()).xpath("//head/ti chapter_links = [{"title": title, "path": path} for title, path in zip(spine_titles, rel_spine_paths)] # Create helper function for getting filename without extension -def get_filename_without_extension(obj): - return os.path.splitext(obj["path"])[0] if obj else "" +def get_filename_without_extension(dict_with_path): + return os.path.splitext(dict_with_path["path"])[0] if dict_with_path else "" # Create footers for i, chapter_link in enumerate(chapter_links): - previousObj = chapter_links[i - 1] if i > 0 else None - nextObj = chapter_links[i + 1] if i < len(chapter_links) - 1 else None + previous_dict = chapter_links[i - 1] if i > 0 else None + next_dict = chapter_links[i + 1] if i < len(chapter_links) - 1 else None - fileName = os.path.join(ebook_dir, "src/epub", chapter_link["path"]) + file_path = os.path.join(ebook_dir, "src/epub", chapter_link["path"]) - previous_link_filename, next_link_filename = [get_filename_without_extension(obj) for obj in [previousObj, nextObj]] + previous_link_filename, next_link_filename = [get_filename_without_extension(chapter_dict) for chapter_dict in [previous_dict, next_dict]] - with open(fileName, "r") as file: + with open(file_path, "r") as file: chapter = file.read() - previousLink = f"""""" if previousObj else "" - nextLink = f"""""" if nextObj else "" + previous_link = f"""""" if previous_dict else "" + next_link = f"""""" if next_dict else "" - footer = f"" + footer = f"" chapter = chapter.replace("", f"{footer}") - with open(fileName, "w") as file: + with open(file_path, "w") as file: file.write(chapter) \ No newline at end of file