summaryrefslogtreecommitdiff
path: root/libmat2/images.py
diff options
context:
space:
mode:
authorjvoisin2023-01-28 15:57:20 +0000
committerjvoisin2023-01-28 15:57:20 +0000
commit39fb254e019c920516bb317d4b48a8de7cac850e (patch)
tree5a5397fe318b8b73f6ebfdb9d1d6c0b64bbda0a3 /libmat2/images.py
parent1f73a16ef36d1a8e771a0b3695818d18e095486b (diff)
Fix the type annotations
Diffstat (limited to 'libmat2/images.py')
-rw-r--r--libmat2/images.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/libmat2/images.py b/libmat2/images.py
index 083ff64..e7cdf5a 100644
--- a/libmat2/images.py
+++ b/libmat2/images.py
@@ -1,6 +1,6 @@
1import os 1import os
2import re 2import re
3from typing import Union, Any 3from typing import Union, Any, Dict
4 4
5import cairo 5import cairo
6 6
@@ -48,7 +48,7 @@ class SVGParser(exiftool.ExiftoolParser):
48 surface.finish() 48 surface.finish()
49 return True 49 return True
50 50
51 def get_meta(self) -> dict[str, Union[str, dict]]: 51 def get_meta(self) -> Dict[str, Union[str, Dict]]:
52 meta = super().get_meta() 52 meta = super().get_meta()
53 53
54 # The namespace is mandatory, but only the …/2000/svg is valid. 54 # The namespace is mandatory, but only the …/2000/svg is valid.
@@ -57,6 +57,7 @@ class SVGParser(exiftool.ExiftoolParser):
57 meta.pop('Xmlns') 57 meta.pop('Xmlns')
58 return meta 58 return meta
59 59
60
60class PNGParser(exiftool.ExiftoolParser): 61class PNGParser(exiftool.ExiftoolParser):
61 mimetypes = {'image/png', } 62 mimetypes = {'image/png', }
62 meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', 63 meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName',
@@ -156,11 +157,12 @@ class TiffParser(GdkPixbufAbstractParser):
156 'FileTypeExtension', 'ImageHeight', 'ImageSize', 157 'FileTypeExtension', 'ImageHeight', 'ImageSize',
157 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'} 158 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'}
158 159
160
159class PPMParser(abstract.AbstractParser): 161class PPMParser(abstract.AbstractParser):
160 mimetypes = {'image/x-portable-pixmap'} 162 mimetypes = {'image/x-portable-pixmap'}
161 163
162 def get_meta(self) -> dict[str, Union[str, dict]]: 164 def get_meta(self) -> Dict[str, Union[str, Dict]]:
163 meta = {} # type: dict[str, Union[str, dict[Any, Any]]] 165 meta = {} # type: Dict[str, Union[str, Dict[Any, Any]]]
164 with open(self.filename) as f: 166 with open(self.filename) as f:
165 for idx, line in enumerate(f): 167 for idx, line in enumerate(f):
166 if line.lstrip().startswith('#'): 168 if line.lstrip().startswith('#'):
@@ -176,9 +178,10 @@ class PPMParser(abstract.AbstractParser):
176 fout.write(line) 178 fout.write(line)
177 return True 179 return True
178 180
181
179class HEICParser(exiftool.ExiftoolParser): 182class HEICParser(exiftool.ExiftoolParser):
180 mimetypes = {'image/heic'} 183 mimetypes = {'image/heic'}
181 meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName','Directory', 184 meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', 'Directory',
182 'FileSize', 'FileModifyDate', 'FileAccessDate', 185 'FileSize', 'FileModifyDate', 'FileAccessDate',
183 'FileInodeChangeDate', 'FilePermissions', 'FileType', 186 'FileInodeChangeDate', 'FilePermissions', 'FileType',
184 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion', 187 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion',