fix: read the guides file with the source loader

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 05:59:51 +01:00
1 parent 26c45da318
commit d4aae50601
2 files changed
+9 -3

No files matched your search

+2 -3
View File
@@ -9,7 +9,7 @@ from pathlib import Path
from model.registry import load_platform_registry
from core.paths import REPO_ROOT
from model.safeparse import require_yaml
from model.sources import source_yaml
SH_NAME = "i"
@@ -343,11 +343,10 @@ def load_guides(path: Path = GUIDES_FILE, registry: dict | None = None) -> dict:
describes. A mistake raises GuideError naming the key, so the site is
never built from half a guide.
"""
yaml = require_yaml()
if registry is None:
registry = load_platform_registry(PLATFORMS_DIR, required=True)
with open(path, encoding="utf-8") as handle:
data = yaml.safe_load(handle) or {}
data = source_yaml(handle) or {}
if not isinstance(data, dict):
raise GuideError(f"{path.name}: expected a mapping")
_unknown(data, _TOP_KEYS, path.name)
+7
View File
@@ -22,6 +22,7 @@ import yaml
from sitegen import decorate
from sitegen import nav as sitegen_nav
from model import guides
from core.cli import SourceUnreadable
from model.guides import GUIDES, GuideError, load_guides
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -76,6 +77,12 @@ class GuidesLiveInYaml(unittest.TestCase):
with self.assertRaisesRegex(GuideError, r"guides\.lakka\.run: no terminal named telnet"):
self._load(yaml.safe_dump(data))
def test_a_repeated_guide_is_refused_with_its_line(self):
"""safe_load kept the second retroarch guide and dropped the first."""
text = _guides_text().replace("guides:\n", "guides:\n lakka: {}\n", 1)
with self.assertRaisesRegex(SourceUnreadable, r"_guides\.yml:\d+: duplicate key 'lakka'"):
self._load(text)
def test_a_folder_row_without_path_is_the_extract_folder(self):
"""The folder the pack unzips into is written once, in the registry."""
registry = _registry()