diff options
Diffstat (limited to 'pyblackbird_cc/resources/views.py')
-rw-r--r-- | pyblackbird_cc/resources/views.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/pyblackbird_cc/resources/views.py b/pyblackbird_cc/resources/views.py index f802350..ca7ce73 100644 --- a/pyblackbird_cc/resources/views.py +++ b/pyblackbird_cc/resources/views.py @@ -3,6 +3,7 @@ import os import tempfile from collections.abc import Generator from dataclasses import dataclass +from typing import Optional from django.conf import settings from django.contrib import messages @@ -45,10 +46,10 @@ class ResourceInfo: subcategories: str | None age_range: str | None pdf_filenames: list[str] - pdf_urls: list[str] + pdf_urls: list[Optional[str]] snapshot_urls: dict[str, list[str]] thumbnail_filenames: list[str] - thumbnail_urls: list[str] + thumbnail_urls: list[Optional[str]] feature_slot: int created: str updated: str @@ -114,8 +115,8 @@ def _extract_metadata_from_resource(resource_obj) -> ResourceInfo | None: created=resource_obj.created_at, updated=resource_obj.updated_at, ) - except Exception as e: - logging.exception(f"Error extracting resource information: {e}") + except Exception: + logging.exception("Error extracting resource information: ") return None @@ -147,16 +148,6 @@ def index(request): return render(request, "resources/resource_list.html", context) -def _write_pdf_to_tempdir(f) -> str: - temp_dir = tempfile.mkdtemp() - file_path = os.path.join(temp_dir, f.name) - - with open(file_path, "wb") as destination: - for chunk in f.chunks(): - destination.write(chunk) - return file_path - - def create_metadata(pdf_files) -> Generator[tuple[services.PDFMetadata, str], None, None]: """ Generates PDF metadata and snapshot images for a list of PDF files. |