mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 03:18:52 -06:00
fix: read site manifests and archives from inputs
This commit is contained in:
1 parent
35b5458a2d
commit
137035d28b
7 files changed
+65
-17
No files matched your search
@@ -626,7 +626,7 @@ def _write_navigation(run: _SiteRun, published_parts: dict[str, str]) -> None:
|
||||
sys_id for cov in coverages.values() for sys_id in cov["config"].get("systems", {})
|
||||
}
|
||||
titles = {sys_id: system_name(sys_id) for sys_id in sorted(system_ids)}
|
||||
sitestarlight.picker_data(REPO_ROOT / "install", public / "data" / "picker", titles)
|
||||
sitestarlight.picker_data(siteinputs.manifests_dir(), public / "data" / "picker", titles)
|
||||
total_pages = len(present)
|
||||
print(f"\nGenerated {total_pages} pages in {run.args.docs_dir}/")
|
||||
if stale:
|
||||
|
||||
@@ -12,6 +12,7 @@ from collections.abc import Callable
|
||||
|
||||
from core.text import series
|
||||
from core.hashing import parse_hash_list
|
||||
from model import siteinputs
|
||||
from model.collection import profiles_on_disk
|
||||
from packs.crossref import FileConsumers
|
||||
from romrecipes.romsets import dat_snapshots, usable_recipe
|
||||
@@ -374,7 +375,7 @@ def _romset_line(f: dict) -> str:
|
||||
when no recipe names the archive or the file is not on disk.
|
||||
"""
|
||||
recipes = romset_releases().get(str(f.get("name", "")))
|
||||
path = REPO_ROOT / str(f.get("path", ""))
|
||||
path = siteinputs.collection_path(str(f.get("path", "")))
|
||||
if not recipes or not path.is_file():
|
||||
return ""
|
||||
try:
|
||||
|
||||
@@ -12,7 +12,6 @@ from xml.sax.saxutils import escape
|
||||
|
||||
from model.registry import load_platform_registry
|
||||
from model.sources import source_yaml_file
|
||||
from core.paths import REPO_ROOT
|
||||
from core.text import count_text
|
||||
from model import siteinputs
|
||||
from sitegen import markup
|
||||
@@ -529,9 +528,13 @@ def _mode_summary() -> str:
|
||||
MINUI_EXAMPLES = (("Sony PlayStation", "PS"), ("Game Boy Advance", "GBA"), ("Sega Genesis", "MD"))
|
||||
|
||||
|
||||
@cache
|
||||
def minui_files() -> dict[str, list[str]]:
|
||||
manifest = json.loads((REPO_ROOT / "install" / "minui.json").read_text(encoding="utf-8"))
|
||||
return _minui_files_in(str(siteinputs.manifests_dir()))
|
||||
|
||||
|
||||
@cache
|
||||
def _minui_files_in(manifests_dir: str) -> dict[str, list[str]]:
|
||||
manifest = json.loads((Path(manifests_dir) / "minui.json").read_text(encoding="utf-8"))
|
||||
by_tag: dict[str, list[str]] = {}
|
||||
for entry in manifest.get("files", []):
|
||||
parts = str(entry.get("dest", "")).split("/")
|
||||
|
||||
@@ -21,7 +21,6 @@ from model.registry import load_platform_registry
|
||||
from resolve.nativemode import digest_algorithm
|
||||
from installer_build.handhelds import GROUP_PAGE
|
||||
from sitegen import handheld as sitehandheld, markup
|
||||
from core.paths import REPO_ROOT
|
||||
from core.sizes import size_text
|
||||
from sitegen.guides import platform_args, terminal_tabs
|
||||
from sitegen.home import next_block
|
||||
@@ -299,7 +298,7 @@ def _computer_first(name: str, guide: Guide) -> bool:
|
||||
def _ships_neogeo(name: str) -> bool:
|
||||
"""Whether the setup's files hold `neogeo.zip`, the archive a reader most
|
||||
often unzips by mistake: arcade BIOS sets are read zipped."""
|
||||
manifest = REPO_ROOT / "install" / f"{name}.json"
|
||||
manifest = siteinputs.manifests_dir() / f"{name}.json"
|
||||
if not manifest.is_file():
|
||||
return False
|
||||
files = json.loads(manifest.read_text(encoding="utf-8")).get("files", [])
|
||||
|
||||
@@ -8,6 +8,7 @@ import json
|
||||
import re
|
||||
import shlex
|
||||
from collections import Counter
|
||||
from pathlib import Path
|
||||
|
||||
from core.text import series
|
||||
from model import siteinputs
|
||||
@@ -20,7 +21,6 @@ from resolve.layout import runs_standalone, standalone_layout_path
|
||||
from resolve.standalone import standalone_set
|
||||
from resolve.validation import installed_everywhere, installed_with_emulator
|
||||
from sitegen import markup
|
||||
from core.paths import REPO_ROOT
|
||||
from installer_build.module import installer_module
|
||||
from sitegen.fields import search_excluded
|
||||
from sitegen.guides import fence, platform_args, terminal_tabs
|
||||
@@ -42,11 +42,15 @@ 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"
|
||||
return _manifest_systems_in(str(siteinputs.manifests_dir()), platform)
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _manifest_systems_in(manifests_dir: str, platform: str) -> frozenset[str]:
|
||||
manifest = Path(manifests_dir) / f"{platform}.json"
|
||||
if not manifest.is_file():
|
||||
return frozenset()
|
||||
document = json.loads(manifest.read_text(encoding="utf-8"))
|
||||
@@ -111,13 +115,17 @@ def install_commands(args: str = "", indent: str = "",
|
||||
return lines
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _published_emulator_names() -> dict[str, dict[str, str]]:
|
||||
"""Per published manifest, every name `--emulator` accepts there and the
|
||||
profile it stands for, as `install.py --list-emulators` prints them."""
|
||||
return _published_emulator_names_in(str(siteinputs.manifests_dir()))
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _published_emulator_names_in(manifests_dir: str) -> dict[str, dict[str, str]]:
|
||||
installer = installer_module()
|
||||
names: dict[str, dict[str, str]] = {}
|
||||
for path in sorted((REPO_ROOT / "install").glob("*.json")):
|
||||
for path in sorted(Path(manifests_dir).glob("*.json")):
|
||||
manifest = json.loads(path.read_text(encoding="utf-8"))
|
||||
names[path.stem] = installer.emulator_names(
|
||||
manifest, manifest.get("files") or [], manifest.get("omitted_files") or [])
|
||||
|
||||
@@ -113,11 +113,11 @@ def generate_files_page() -> str:
|
||||
])
|
||||
|
||||
|
||||
def data_directory_members(install_dir: Path = REPO_ROOT / "install") -> dict[str, dict[str, dict]]:
|
||||
def data_directory_members(install_dir: Path | None = None) -> dict[str, dict[str, dict]]:
|
||||
"""Each data directory's files with their sha1 and size, as the install
|
||||
manifests record them for the installer to check."""
|
||||
members: dict[str, dict[str, dict]] = {}
|
||||
for path in sorted(install_dir.glob("*.json")):
|
||||
for path in sorted((install_dir or siteinputs.manifests_dir()).glob("*.json")):
|
||||
manifest = json.loads(path.read_text(encoding="utf-8"))
|
||||
for tree in manifest.get("data_directories") or []:
|
||||
members.setdefault(str(tree.get("ref", "")), {}).update(tree.get("files") or {})
|
||||
@@ -318,7 +318,7 @@ def retired_records(retired: dict[str, dict], files: dict, locations: list[dict]
|
||||
|
||||
|
||||
def _archive_member_records(entry: dict, sha1: str, url: str,
|
||||
root: Path = REPO_ROOT) -> list[dict]:
|
||||
root: Path | None = None) -> list[dict]:
|
||||
"""The CRC32 of each member of a collection archive, read from its
|
||||
central directory.
|
||||
|
||||
@@ -326,7 +326,8 @@ def _archive_member_records(entry: dict, sha1: str, url: str,
|
||||
in a500.zip, 8484f426) found nothing: 26,014 of 33,403 members were in
|
||||
no record. The record leads to the archive's card and names it.
|
||||
"""
|
||||
path = root / str(entry.get("path", ""))
|
||||
rel = str(entry.get("path", ""))
|
||||
path = root / rel if root is not None else siteinputs.collection_path(rel)
|
||||
if not is_archive_path(path.name) or not path.is_file():
|
||||
return []
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user