diff --git a/src/python/media_cache.py b/src/python/media_cache.py index b1765d4a..ae03e463 100644 --- a/src/python/media_cache.py +++ b/src/python/media_cache.py @@ -4,7 +4,7 @@ import io import re from dataclasses import dataclass, field from pathlib import Path -from typing import Any, DefaultDict, Dict, Optional, Tuple +from typing import Any, DefaultDict, Dict, Optional from urllib.parse import urlparse import aiofiles @@ -13,9 +13,9 @@ from PIL import Image as PILImage import nio from .backend import Backend +from .utils import Size CryptDict = Optional[Dict[str, Any]] -Size = Tuple[int, int] CONCURRENT_DOWNLOADS_LIMIT = asyncio.BoundedSemaphore(8) ACCESS_LOCKS: DefaultDict[str, asyncio.Lock] = DefaultDict(asyncio.Lock) diff --git a/src/python/utils.py b/src/python/utils.py index 817c84b4..ca533105 100644 --- a/src/python/utils.py +++ b/src/python/utils.py @@ -16,6 +16,7 @@ from typing import IO, Any, Callable, Dict, Tuple, Type, Union import filetype File = Union[IO, bytes, str, Path] +Size = Tuple[int, int] auto = autostr CANCELLABLE_FUTURES: Dict[Tuple[Any, Callable], asyncio.Future] = {} @@ -59,7 +60,7 @@ def is_svg(file: File) -> bool: return False -def svg_dimensions(file: File) -> Tuple[int, int]: +def svg_dimensions(file: File) -> Size: """Return the width & height or viewBox width & height for a SVG. If these properties are missing (broken file), ``(256, 256)`` is returned. """