Spaces:
Running
Running
File size: 835 Bytes
008947a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | """Export naming and artifact helpers."""
from __future__ import annotations
from datetime import datetime
from pathlib import Path
from .models import OutputFormat
from .paths import POSTERS_DIR
from .typography import safe_slug
def generate_output_filename(
place: str,
style_id: str,
output_format: OutputFormat | str,
directory: str | Path = POSTERS_DIR,
*,
include_time: bool = True,
) -> str:
"""Return a readable, collision-resistant poster filename."""
output_dir = Path(directory)
output_dir.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d-%H%M%S" if include_time else "%Y%m%d")
extension = OutputFormat(output_format).value
filename = f"{safe_slug(place)}-{safe_slug(style_id)}-{timestamp}.{extension}"
return str(output_dir / filename)
|