summaryrefslogtreecommitdiff
path: root/libmat2/epub.py
diff options
context:
space:
mode:
Diffstat (limited to 'libmat2/epub.py')
-rw-r--r--libmat2/epub.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/libmat2/epub.py b/libmat2/epub.py
index 7613d35..3c5046a 100644
--- a/libmat2/epub.py
+++ b/libmat2/epub.py
@@ -3,10 +3,11 @@ import re
3import uuid 3import uuid
4import zipfile 4import zipfile
5import xml.etree.ElementTree as ET # type: ignore 5import xml.etree.ElementTree as ET # type: ignore
6from typing import Any 6from typing import Any, Dict
7 7
8from . import archive, office 8from . import archive, office
9 9
10
10class EPUBParser(archive.ZipParser): 11class EPUBParser(archive.ZipParser):
11 mimetypes = {'application/epub+zip', } 12 mimetypes = {'application/epub+zip', }
12 metadata_namespace = '{http://purl.org/dc/elements/1.1/}' 13 metadata_namespace = '{http://purl.org/dc/elements/1.1/}'
@@ -28,7 +29,6 @@ class EPUBParser(archive.ZipParser):
28 })) 29 }))
29 self.uniqid = uuid.uuid4() 30 self.uniqid = uuid.uuid4()
30 31
31
32 def is_archive_valid(self): 32 def is_archive_valid(self):
33 super().is_archive_valid() 33 super().is_archive_valid()
34 with zipfile.ZipFile(self.filename) as zin: 34 with zipfile.ZipFile(self.filename) as zin:
@@ -37,7 +37,7 @@ class EPUBParser(archive.ZipParser):
37 if member_name.endswith('META-INF/encryption.xml'): 37 if member_name.endswith('META-INF/encryption.xml'):
38 raise ValueError('the file contains encrypted fonts') 38 raise ValueError('the file contains encrypted fonts')
39 39
40 def _specific_get_meta(self, full_path, file_path) -> dict[str, Any]: 40 def _specific_get_meta(self, full_path, file_path) -> Dict[str, Any]:
41 if not file_path.endswith('.opf'): 41 if not file_path.endswith('.opf'):
42 return {} 42 return {}
43 43
@@ -73,7 +73,6 @@ class EPUBParser(archive.ZipParser):
73 short_empty_elements=False) 73 short_empty_elements=False)
74 return True 74 return True
75 75
76
77 def __handle_tocncx(self, full_path: str) -> bool: 76 def __handle_tocncx(self, full_path: str) -> bool:
78 try: 77 try:
79 tree, namespace = office._parse_xml(full_path) 78 tree, namespace = office._parse_xml(full_path)