{card['description']}
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import base64
import json
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "renderer"))
from app.renderer import render_documents
from app.theme_catalog import THEMES
from app.validation import validate_report
def command(name: str, override: str | None = None) -> str:
value = override or shutil.which(name)
if not value:
raise SystemExit(f"Benötigtes Programm nicht gefunden: {name}")
return value
def print_pdf(engine: str, executable: str, html_path: Path, pdf_path: Path) -> None:
if engine == "weasyprint":
subprocess.run(
[executable, str(html_path), str(pdf_path)],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=90,
)
return
subprocess.run(
[
executable,
"--headless=new",
"--no-sandbox",
"--disable-gpu",
"--disable-dev-shm-usage",
"--disable-background-networking",
"--disable-extensions",
"--no-first-run",
f"--user-data-dir={pdf_path.parent / ('.chrome-' + pdf_path.stem)}",
f"--print-to-pdf={pdf_path.resolve()}",
"--no-pdf-header-footer",
html_path.resolve().as_uri(),
],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
timeout=90,
)
def first_page_png(pdftoppm: str, pdf_path: Path, png_path: Path) -> None:
prefix = png_path.with_suffix("")
subprocess.run(
[pdftoppm, "-f", "1", "-singlefile", "-scale-to", "760", "-png", str(pdf_path), str(prefix)],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
def make_gallery(cards: list[dict[str, str]], output: Path) -> None:
blocks = []
for card in cards:
image_data = base64.b64encode(Path(card["image"]).read_bytes()).decode("ascii")
swatches = "".join(f'' for color in card["colors"].split(","))
blocks.append(
f''' {card['description']}
28 Designs in 10 Layoutfamilien
Auswahl über design.theme