mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Name the packaged file by Document Type with the original extension 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
63933db529
commit
b89b9fe944
1 changed files with 10 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ orchestrator does the S3/DB work; this module only lays out the archive.
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import posixpath
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from typing import Optional, Sequence
|
||||
|
|
@ -57,6 +58,14 @@ class DownloadPackagePlan:
|
|||
skipped: tuple[SkippedDocument, ...]
|
||||
|
||||
|
||||
def _extension_of(s3_key: str) -> str:
|
||||
"""The file extension of an S3 key (``.pdf``, ``.zip``, …), empty when the
|
||||
key's basename has none. Used to keep the packaged file openable while
|
||||
naming it by Document Type."""
|
||||
_root, ext = posixpath.splitext(posixpath.basename(s3_key))
|
||||
return ext
|
||||
|
||||
|
||||
def plan_download_package(
|
||||
documents: Sequence[ResolvedDocument],
|
||||
) -> DownloadPackagePlan:
|
||||
|
|
@ -83,7 +92,7 @@ def plan_download_package(
|
|||
entries: list[PackageEntry] = [
|
||||
PackageEntry(
|
||||
zip_path=f"{document.address} ({document.landlord_property_id})/"
|
||||
f"{document.document_type}",
|
||||
f"{document.document_type}{_extension_of(document.s3_key)}",
|
||||
s3_bucket=document.s3_bucket,
|
||||
s3_key=document.s3_key,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue