From 39fb254e019c920516bb317d4b48a8de7cac850e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 28 Jan 2023 15:57:20 +0000 Subject: Fix the type annotations --- libmat2/images.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'libmat2/images.py') 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 @@ import os import re -from typing import Union, Any +from typing import Union, Any, Dict import cairo @@ -48,7 +48,7 @@ class SVGParser(exiftool.ExiftoolParser): surface.finish() return True - def get_meta(self) -> dict[str, Union[str, dict]]: + def get_meta(self) -> Dict[str, Union[str, Dict]]: meta = super().get_meta() # The namespace is mandatory, but only the …/2000/svg is valid. @@ -57,6 +57,7 @@ class SVGParser(exiftool.ExiftoolParser): meta.pop('Xmlns') return meta + class PNGParser(exiftool.ExiftoolParser): mimetypes = {'image/png', } meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', @@ -156,11 +157,12 @@ class TiffParser(GdkPixbufAbstractParser): 'FileTypeExtension', 'ImageHeight', 'ImageSize', 'ImageWidth', 'MIMEType', 'Megapixels', 'SourceFile'} + class PPMParser(abstract.AbstractParser): mimetypes = {'image/x-portable-pixmap'} - def get_meta(self) -> dict[str, Union[str, dict]]: - meta = {} # type: dict[str, Union[str, dict[Any, Any]]] + def get_meta(self) -> Dict[str, Union[str, Dict]]: + meta = {} # type: Dict[str, Union[str, Dict[Any, Any]]] with open(self.filename) as f: for idx, line in enumerate(f): if line.lstrip().startswith('#'): @@ -176,9 +178,10 @@ class PPMParser(abstract.AbstractParser): fout.write(line) return True + class HEICParser(exiftool.ExiftoolParser): mimetypes = {'image/heic'} - meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName','Directory', + meta_allowlist = {'SourceFile', 'ExifToolVersion', 'FileName', 'Directory', 'FileSize', 'FileModifyDate', 'FileAccessDate', 'FileInodeChangeDate', 'FilePermissions', 'FileType', 'FileTypeExtension', 'MIMEType', 'MajorBrand', 'MinorVersion', -- cgit v1.3