From f6ab58eb784b10101eb28095731b54cda8a73e7a Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 20 Jan 2020 17:56:21 -0800 Subject: [PATCH] Add these ### headers above the helper functions. I'm trying to decide if I should create function classes to hold these things, but for now these headers will do. --- epubfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/epubfile.py b/epubfile.py index 728fd56..4fe8c24 100644 --- a/epubfile.py +++ b/epubfile.py @@ -127,6 +127,8 @@ TEXT_TEMPLATE = ''' '''.strip() +# EPUB COMPRESSION +################################################################################ def compress_epub(directory, epub_filepath): directory = pathclass.Path(directory) epub_filepath = pathclass.Path(epub_filepath) @@ -156,6 +158,8 @@ def extract_epub(epub_filepath, directory): with zipfile.ZipFile(epub_filepath.absolute_path, 'r') as z: z.extractall(directory.absolute_path) +# XHTML TOOLS +################################################################################ def fix_xhtml(xhtml, return_soup=False): if isinstance(xhtml, bs4.BeautifulSoup): soup = xhtml @@ -241,6 +245,8 @@ def promote_xhtml_headers(xhtml, return_soup=False): ] return xhtml_replacements(xhtml, replacements, return_soup=return_soup) +# MIMETYPE DECISIONMAKERS +################################################################################ def get_directory_for_mimetype(mime): directory = ( MIMETYPE_DIRECTORIES.get(mime) or @@ -258,6 +264,8 @@ def get_mimetype_for_basename(basename): ) return mime +# OPF ELEMENT GENERATORS +################################################################################ def make_manifest_item(id, href, mime): manifest_item = f'' # 'html.parser' just for having the simplest output.