diff options
| author | jvoisin | 2023-01-28 15:57:20 +0000 |
|---|---|---|
| committer | jvoisin | 2023-01-28 15:57:20 +0000 |
| commit | 39fb254e019c920516bb317d4b48a8de7cac850e (patch) | |
| tree | 5a5397fe318b8b73f6ebfdb9d1d6c0b64bbda0a3 /libmat2/epub.py | |
| parent | 1f73a16ef36d1a8e771a0b3695818d18e095486b (diff) | |
Fix the type annotations
Diffstat (limited to 'libmat2/epub.py')
| -rw-r--r-- | libmat2/epub.py | 7 |
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 | |||
| 3 | import uuid | 3 | import uuid |
| 4 | import zipfile | 4 | import zipfile |
| 5 | import xml.etree.ElementTree as ET # type: ignore | 5 | import xml.etree.ElementTree as ET # type: ignore |
| 6 | from typing import Any | 6 | from typing import Any, Dict |
| 7 | 7 | ||
| 8 | from . import archive, office | 8 | from . import archive, office |
| 9 | 9 | ||
| 10 | |||
| 10 | class EPUBParser(archive.ZipParser): | 11 | class 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) |
