mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: read manifest systems once per platform
This commit is contained in:
1 parent
3f33b1c247
commit
8f29887bda
3 files changed
+19
-30
No files matched your search
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import urllib.parse
|
||||
@@ -18,7 +17,7 @@ from romrecipes.romsets import dat_snapshots, usable_recipe
|
||||
from sitegen import markup, wanted as sitewanted
|
||||
from core.paths import REPO_ROOT
|
||||
from sitegen.fields import search_excluded
|
||||
from sitegen.install import platform_display
|
||||
from sitegen.install import manifest_systems, platform_display
|
||||
from sitegen.render import code_span, count_text, system_page_map, emulator_card_page
|
||||
|
||||
|
||||
@@ -756,15 +755,7 @@ def system_install_choices(coverages: dict) -> dict[str, dict[str, list[tuple[st
|
||||
|
||||
choices: dict[str, dict[str, list[tuple[str, str]]]] = {}
|
||||
for name, cov in sorted(coverages.items()):
|
||||
manifest = REPO_ROOT / "install" / f"{name}.json"
|
||||
if not manifest.is_file():
|
||||
continue
|
||||
document = json.loads(manifest.read_text(encoding="utf-8"))
|
||||
recorded = {
|
||||
str(system)
|
||||
for entry in (document.get("files") or []) + (document.get("omitted_files") or [])
|
||||
for system in entry.get("systems") or []
|
||||
}
|
||||
recorded = manifest_systems(name)
|
||||
for sys_id in sorted(set(cov["config"].get("systems") or {}) & recorded):
|
||||
page = system_page_map.get(sys_id) or page_by_norm(sys_id)
|
||||
if page:
|
||||
|
||||
@@ -39,6 +39,21 @@ def _release_packs_in(platforms_dir: str) -> frozenset[str]:
|
||||
return frozenset(list_release_pack_platforms(platforms_dir))
|
||||
|
||||
|
||||
@functools.cache
|
||||
def manifest_systems(platform: str) -> frozenset[str]:
|
||||
"""The system ids a platform's install manifest records: --system
|
||||
refuses any other."""
|
||||
manifest = REPO_ROOT / "install" / f"{platform}.json"
|
||||
if not manifest.is_file():
|
||||
return frozenset()
|
||||
document = json.loads(manifest.read_text(encoding="utf-8"))
|
||||
return frozenset(
|
||||
str(system)
|
||||
for entry in (document.get("files") or []) + (document.get("omitted_files") or [])
|
||||
for system in entry.get("systems") or []
|
||||
)
|
||||
|
||||
|
||||
_platform_names: dict[str, str] = {}
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import functools
|
||||
import html
|
||||
import json
|
||||
import re
|
||||
@@ -16,7 +15,6 @@ from packs.crossref import FileConsumers
|
||||
from sitegen import markup
|
||||
from sitegen.cards import icon_symbol
|
||||
from sitegen.config import date_line
|
||||
from core.paths import REPO_ROOT
|
||||
from sitegen.consolecards import (
|
||||
CARD_HTML_RATIO,
|
||||
CONSOLE_PAGES,
|
||||
@@ -30,7 +28,7 @@ from sitegen.consolecards import (
|
||||
from sitegen.decorate import DEMOTED_WEIGHT, SEARCH_WEIGHT
|
||||
from sitegen.fields import search_excluded
|
||||
from sitegen.home import next_block
|
||||
from sitegen.install import console_install_block, platform_display
|
||||
from sitegen.install import console_install_block, manifest_systems, platform_display
|
||||
from sitegen.parts import character_count, even_runs, parent_front_matter, part_stems, weighted_runs
|
||||
from sitegen.render import count_text, slugify_anchor, console_href, record_console_pages
|
||||
from sitegen.startwith import (
|
||||
@@ -243,21 +241,6 @@ def _part_weight() -> float:
|
||||
return SEARCH_WEIGHT.get("part", DEMOTED_WEIGHT)
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _manifest_systems(platform: str) -> frozenset[str]:
|
||||
"""The system ids a platform's install manifest records: --system
|
||||
refuses any other."""
|
||||
manifest = REPO_ROOT / "install" / f"{platform}.json"
|
||||
if not manifest.is_file():
|
||||
return frozenset()
|
||||
document = json.loads(manifest.read_text(encoding="utf-8"))
|
||||
return frozenset(
|
||||
str(system)
|
||||
for entry in (document.get("files") or []) + (document.get("omitted_files") or [])
|
||||
for system in entry.get("systems") or []
|
||||
)
|
||||
|
||||
|
||||
def _install_pairs(
|
||||
declared: list[tuple[str, str]], lead: str | None, consumers: FileConsumers,
|
||||
) -> list[tuple[str, str]]:
|
||||
@@ -270,7 +253,7 @@ def _install_pairs(
|
||||
.get(lead or "", {}).items()):
|
||||
if platform in have:
|
||||
continue
|
||||
recorded = [s for s in sorted(systems) if s in _manifest_systems(platform)]
|
||||
recorded = [s for s in sorted(systems) if s in manifest_systems(platform)]
|
||||
if recorded:
|
||||
pairs.append((platform, recorded[0]))
|
||||
have.add(platform)
|
||||
|
||||
Reference in new issue
Block a user