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/pdf.py | |
| parent | 1f73a16ef36d1a8e771a0b3695818d18e095486b (diff) | |
Fix the type annotations
Diffstat (limited to 'libmat2/pdf.py')
| -rw-r--r-- | libmat2/pdf.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libmat2/pdf.py b/libmat2/pdf.py index 63ed9c1..8c3055f 100644 --- a/libmat2/pdf.py +++ b/libmat2/pdf.py | |||
| @@ -7,7 +7,7 @@ import re | |||
| 7 | import logging | 7 | import logging |
| 8 | import tempfile | 8 | import tempfile |
| 9 | import io | 9 | import io |
| 10 | from typing import Union | 10 | from typing import Union, Dict |
| 11 | 11 | ||
| 12 | import cairo | 12 | import cairo |
| 13 | import gi | 13 | import gi |
| @@ -18,6 +18,7 @@ from . import abstract | |||
| 18 | 18 | ||
| 19 | FIXED_PDF_VERSION = cairo.PDFVersion.VERSION_1_5 | 19 | FIXED_PDF_VERSION = cairo.PDFVersion.VERSION_1_5 |
| 20 | 20 | ||
| 21 | |||
| 21 | class PDFParser(abstract.AbstractParser): | 22 | class PDFParser(abstract.AbstractParser): |
| 22 | mimetypes = {'application/pdf', } | 23 | mimetypes = {'application/pdf', } |
| 23 | meta_list = {'author', 'creation-date', 'creator', 'format', 'keywords', | 24 | meta_list = {'author', 'creation-date', 'creator', 'format', 'keywords', |
| @@ -140,13 +141,13 @@ class PDFParser(abstract.AbstractParser): | |||
| 140 | return True | 141 | return True |
| 141 | 142 | ||
| 142 | @staticmethod | 143 | @staticmethod |
| 143 | def __parse_metadata_field(data: str) -> dict[str, str]: | 144 | def __parse_metadata_field(data: str) -> Dict[str, str]: |
| 144 | metadata = {} | 145 | metadata = {} |
| 145 | for (_, key, value) in re.findall(r"<(xmp|pdfx|pdf|xmpMM):(.+)>(.+)</\1:\2>", data, re.I): | 146 | for (_, key, value) in re.findall(r"<(xmp|pdfx|pdf|xmpMM):(.+)>(.+)</\1:\2>", data, re.I): |
| 146 | metadata[key] = value | 147 | metadata[key] = value |
| 147 | return metadata | 148 | return metadata |
| 148 | 149 | ||
| 149 | def get_meta(self) -> dict[str, Union[str, dict]]: | 150 | def get_meta(self) -> Dict[str, Union[str, Dict]]: |
| 150 | """ Return a dict with all the meta of the file | 151 | """ Return a dict with all the meta of the file |
| 151 | """ | 152 | """ |
| 152 | metadata = {} | 153 | metadata = {} |
