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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 19:06:54 +01:00
1 parent c624a820f0
commit cf7b2ad9c1
2 files changed
+22 -2

No files matched your search

+3 -2
View File
@@ -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...")
+19
View File
@@ -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"])