Skip to content

Commit

Permalink
[FIX] typing syntyax for Python3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Segolene-Albouy committed Dec 11, 2024
1 parent 8a5fc2d commit e698329
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/iiif_download/downloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Optional
from typing import Optional, Union
from urllib.parse import unquote

from .config import config
Expand All @@ -11,7 +11,7 @@
class IIIFDownloader:
"""Manages the download of IIIF manifests and their images."""

def __init__(self, img_dir: Optional[Path | str] = None):
def __init__(self, img_dir: Optional[Union[Path, str]] = None):
self.img_dir = img_dir

@staticmethod
Expand All @@ -20,7 +20,7 @@ def add_to_log(log_file, msg: str, mode="a"):
with open(log_file, mode) as f:
f.write(f"{msg}\n")

def download_manifest(self, url: str, save_dir: Optional[Path | str] = None) -> bool | IIIFManifest:
def download_manifest(self, url: str, save_dir: Optional[Union[Path, str]] = None) -> bool | IIIFManifest:
"""Download a complete manifest and all its images."""
url = unquote(url)
manifest = IIIFManifest(url, img_dir=self.img_dir, manifest_dir_name=save_dir)
Expand Down
4 changes: 2 additions & 2 deletions src/iiif_download/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class IIIFManifest:
"""
Mapping of all image names to their URLs.
"""
img_mapping: dict[str, str] = {}
img_mapping: Dict[str, str] = {}

def __init__(self, url: str, img_dir: Path = None, manifest_dir_name: str = None):
self.url = url
self.content: Optional[dict[str, Any]] = None
self.content: Optional[Dict[str, Any]] = None
self.manifest_dir: Path = (Path(img_dir) if img_dir else config.img_dir) / (
manifest_dir_name or self.get_dir_name()
)
Expand Down

0 comments on commit e698329

Please sign in to comment.