Spaces:
Running
Running
Download src/maptoposter/export.py from isaachwf/MapToPoster: direct link, hf CLI and curl.
- Browser
- Download file 835 Bytes
-
https://huggingface.co/spaces/isaachwf/MapToPoster/resolve/main/src/maptoposter/export.py
- Command line
-
hf download hf://spaces/isaachwf/MapToPoster/src/maptoposter/export.py
-
curl -L -o export.py https://huggingface.co/spaces/isaachwf/MapToPoster/resolve/main/src/maptoposter/export.py
835 Bytes
| """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) | |