From cf7b2ad9c1b4e0b6f661014616d8994abcbba274 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Thu, 5 Nov 2026 19:06:54 +0100 Subject: [PATCH] fix: install site sections before the page plan plan_emulator_pages names systems, and siterender then fell back to the repository's database.json and emulators/ whatever --db and --emulators-dir gave. --- scripts/generate_site.py | 5 +++-- tests/test_site_system_names.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 5e3fb96a9..b5e1856d2 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -12142,15 +12142,16 @@ def _generate(args: argparse.Namespace) -> None: # The test each emulator page builds for itself: the parts a page is # cut into weigh the status its rows show. file_held = _availability_check(db, suppl_names) + # The plan names systems: the sections must be this run's data first. + manufacturers = _group_by_manufacturer(db) + set_console_sections(manufacturers, program_names(profiles)) plan_emulator_pages(profiles, file_held) # Build system_id -> manufacturer page map (needed by all generators) print("Building system cross-reference map...") - manufacturers = _group_by_manufacturer(db) set_system_page_map( _system_pages_from_data(manufacturers, coverages, db, profiles) ) print(f" {len(_system_page_map)} system IDs mapped to pages") - set_console_sections(manufacturers, program_names(profiles)) from siterender import link_coverage, system_ids # noqa: PLC0415 print("Generating system pages...") diff --git a/tests/test_site_system_names.py b/tests/test_site_system_names.py index da1103b97..b24fc3de8 100644 --- a/tests/test_site_system_names.py +++ b/tests/test_site_system_names.py @@ -118,3 +118,22 @@ class SystemNames(unittest.TestCase): if __name__ == "__main__": unittest.main() + + +class SectionsComeBeforeThePlan(unittest.TestCase): + """plan_emulator_pages names systems. Run before set_console_sections, + it made siterender read ./database.json and ./emulators whatever --db + and --emulators-dir gave, so the parts were cut on another collection.""" + + def test_generate_installs_the_sections_before_planning(self): + import ast + import inspect + + import generate_site + + tree = ast.parse(inspect.getsource(generate_site._generate)) + lines = {} + for node in ast.walk(tree): + if isinstance(node, ast.Call) and isinstance(node.func, ast.Name): + lines.setdefault(node.func.id, node.lineno) + self.assertLess(lines["set_console_sections"], lines["plan_emulator_pages"])