summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmat2/epub.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/libmat2/epub.py b/libmat2/epub.py
index f43667e..83f5728 100644
--- a/libmat2/epub.py
+++ b/libmat2/epub.py
@@ -2,6 +2,7 @@ import logging
2import re 2import re
3import uuid 3import uuid
4import xml.etree.ElementTree as ET # type: ignore 4import xml.etree.ElementTree as ET # type: ignore
5from typing import Dict, Any
5 6
6from . import archive, office 7from . import archive, office
7 8
@@ -38,7 +39,7 @@ class EPUBParser(archive.ZipParser):
38 except (TypeError, UnicodeDecodeError): 39 except (TypeError, UnicodeDecodeError):
39 return {file_path: 'harmful content', } 40 return {file_path: 'harmful content', }
40 41
41 def _specific_cleanup(self, full_path: str): 42 def _specific_cleanup(self, full_path: str) -> bool:
42 if full_path.endswith('hmh.opf') or full_path.endswith('content.opf'): 43 if full_path.endswith('hmh.opf') or full_path.endswith('content.opf'):
43 return self.__handle_contentopf(full_path) 44 return self.__handle_contentopf(full_path)
44 elif full_path.endswith('OEBPS/toc.ncx'): 45 elif full_path.endswith('OEBPS/toc.ncx'):
@@ -47,7 +48,7 @@ class EPUBParser(archive.ZipParser):
47 return self.__handle_ops_xml(full_path) 48 return self.__handle_ops_xml(full_path)
48 return True 49 return True
49 50
50 def __handle_ops_xml(self, full_path: str): 51 def __handle_ops_xml(self, full_path: str) -> bool:
51 try: 52 try:
52 tree, namespace = office._parse_xml(full_path) 53 tree, namespace = office._parse_xml(full_path)
53 except ET.ParseError: # pragma: nocover 54 except ET.ParseError: # pragma: nocover
@@ -63,7 +64,7 @@ class EPUBParser(archive.ZipParser):
63 return True 64 return True
64 65
65 66
66 def __handle_tocncx(self, full_path: str): 67 def __handle_tocncx(self, full_path: str) -> bool:
67 try: 68 try:
68 tree, namespace = office._parse_xml(full_path) 69 tree, namespace = office._parse_xml(full_path)
69 except ET.ParseError: # pragma: nocover 70 except ET.ParseError: # pragma: nocover
@@ -79,7 +80,7 @@ class EPUBParser(archive.ZipParser):
79 short_empty_elements=False) 80 short_empty_elements=False)
80 return True 81 return True
81 82
82 def __handle_contentopf(self, full_path: str): 83 def __handle_contentopf(self, full_path: str) -> bool:
83 try: 84 try:
84 tree, namespace = office._parse_xml(full_path) 85 tree, namespace = office._parse_xml(full_path)
85 except ET.ParseError: 86 except ET.ParseError: