fix: read the given database on every page

The page-finishing pass reloaded the repository's database.json whatever
--db said, so a card held only by the given collection raised KeyError.
siteinputs holds the inputs generate_site was given.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 08:12:43 +01:00
1 parent 19898cb6ea
commit 8022ef4cb3
3 files changed
+110 -7

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
"""The collection, profiles and platform files the site describes.
generate_site.py takes them as --db, --emulators-dir and --platforms-dir and
installs them here before writing a page. Every page module reads its inputs
from current(), so a run on another collection describes that collection on
every page. A module used on its own reads the repository's files.
"""
from __future__ import annotations
from dataclasses import dataclass
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
@dataclass(frozen=True)
class SiteInputs:
db: Path = ROOT / "database.json"
emulators: Path = ROOT / "emulators"
platforms: Path = ROOT / "platforms"
_current = [SiteInputs()]
def current() -> SiteInputs:
return _current[0]
def use(inputs: SiteInputs) -> None:
_current[0] = inputs