fix: read extract folders from the registry

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 12:44:32 +02:00
1 parent 7164e8a125
commit 53c5504330
4 files changed
+126 -33

No files matched your search

+32 -15
View File
@@ -118,6 +118,35 @@ def release_totals(platform_name: str, record: dict) -> tuple[int | None, int |
return pack["files"], pack["extracted_size"]
def extract_targets(platforms_dir: str) -> list[tuple[str, str]]:
"""(display name, folder) per registered platform, where its pack extracts.
Read from the registry so the README, the site and the pack guide answer
from one place. Sorted by display name.
"""
rows = [
(load_platform_config(key, platforms_dir).get("platform", key), entry["extract_to"])
for key, entry in load_platform_registry(platforms_dir).items()
if entry.get("extract_to")
]
return sorted(rows, key=lambda row: row[0].casefold())
def extract_notes(platforms_dir: str) -> list[str]:
"""A pack whose entries carry their own root extracts above the BIOS folder."""
folders = dict(extract_targets(platforms_dir))
notes = []
for key in sorted(load_platform_registry(platforms_dir)):
config = load_platform_config(key, platforms_dir)
display = config.get("platform", key)
if config.get("base_destination") == "" and display in folders:
notes.append(
f"The {display} pack already carries its own `bios/` folder, so it"
f" extracts into `{folders[display]}` rather than into the BIOS folder."
)
return notes
def download_table(
coverages: dict,
archived: set[str],
@@ -365,18 +394,7 @@ def generate_readme(db: dict, platforms_dir: str) -> str:
# a pack whose entries already carry their own root (RetroDECK) extracts
# one level above it.
extract_paths = {
"RetroArch": "`system/`",
"Lakka": "`/storage/system/`",
"Batocera": "`/userdata/bios/`",
"BizHawk": "`Firmware/`",
"Recalbox": "`/recalbox/share/bios/`",
"RetroBat": "`bios/`",
"RetroPie": "`~/RetroPie/BIOS/`",
"RetroDECK": "`~/retrodeck/`",
"EmuDeck": "`~/Emulation/bios/`",
"RomM": "`bios/{platform_slug}/`",
"ROCKNIX": "`/storage/roms/bios/`",
"MiSTer FPGA": "`/media/fat/games/`",
display: f"`{folder}`" for display, folder in extract_targets(platforms_dir)
}
archived = {
name
@@ -390,12 +408,11 @@ def generate_readme(db: dict, platforms_dir: str) -> str:
)
)
for note in extract_notes(platforms_dir):
lines.extend(["", note])
if archived:
lines.extend(
[
"",
"The RetroDECK pack already contains its own `bios/` folder, so it"
" extracts into `~/retrodeck/` rather than into the BIOS folder.",
"",
"\\* Archived: the configuration is kept and packs are still built,"
" but upstream is no longer scraped on a schedule.",
+22 -18
View File
@@ -51,7 +51,13 @@ from nativemode import reads_file_contents
yaml = require_yaml()
from generate_readme import compute_coverage, contributing_text, release_totals
from generate_readme import (
compute_coverage,
contributing_text,
extract_notes,
extract_targets,
release_totals,
)
from profile_sync import source_ref_values, split_source_ref
from provenance_report import build_report
import release_record
@@ -200,7 +206,11 @@ def _timestamp() -> str:
def generate_home(
db: dict, coverages: dict, profiles: dict, registry: dict | None = None
db: dict,
coverages: dict,
profiles: dict,
registry: dict | None = None,
platforms_dir: str = "platforms",
) -> str:
total_files = db.get("total_files", 0)
total_size = db.get("total_size", 0)
@@ -318,22 +328,14 @@ def generate_home(
"",
" | Platform | Extract to |",
" |----------|-----------|",
" | RetroArch | `system/` |",
" | Batocera | `/userdata/bios/` |",
" | BizHawk | `Firmware/` |",
" | EmuDeck | `~/Emulation/bios/` |",
" | Lakka | `/storage/system/` |",
" | MiSTer FPGA | `/media/fat/games/` |",
" | ROCKNIX | `/storage/roms/bios/` |",
" | Recalbox | `/recalbox/share/bios/` |",
" | RetroBat | `bios/` |",
" | RetroDECK | `~/retrodeck/` |",
" | RetroPie | `~/RetroPie/BIOS/` |",
" | RomM | `bios/{platform_slug}/` |",
*(
f" | {display} | `{folder}` |"
for display, folder in extract_targets(platforms_dir)
),
"",
" The RetroDECK pack already carries its own `bios/` folder, so it "
"extracts one level above it. Every other pack extracts straight into "
"the BIOS folder. [Full instructions per setup](which-pack.md).",
*(f" {note}" for note in extract_notes(platforms_dir)),
" Every other pack extracts straight into the BIOS folder."
" [Full instructions per setup](which-pack.md).",
"",
]
)
@@ -3608,7 +3610,9 @@ def main():
# Generate home
print("Generating home page...")
write_if_changed(
str(docs / "index.md"), generate_home(db, coverages, profiles, registry)
str(docs / "index.md"), generate_home(
db, coverages, profiles, registry, args.platforms_dir
)
)
stats = compute_stats(db, coverages, profiles)