mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
fix: carry each gap row's category from crossref
This commit is contained in:
1 parent
e21c3478b4
commit
94fbf8d386
5 files changed
+68
-24
No files matched your search
@@ -347,6 +347,18 @@ def first_hash(entry: dict) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def declared_as(f: dict, fname: str) -> dict[str, str]:
|
||||
"""The category and path the profile gives the entry a row stands for.
|
||||
|
||||
A row's own path is the destination the running build reads, so a
|
||||
reader that needs the profile's declaration takes it from here.
|
||||
"""
|
||||
return {
|
||||
"category": str(f.get("category") or "bios"),
|
||||
"profile_path": str(f.get("path") or fname),
|
||||
}
|
||||
|
||||
|
||||
def slot_key(f: dict, standalone: bool = False) -> tuple:
|
||||
"""The slot a profile entry fills: its entries on one slot are the
|
||||
versions its code accepts there, and holding any of them fills it.
|
||||
@@ -457,6 +469,7 @@ class _ProfileComparison:
|
||||
"required": f.get("required", False),
|
||||
"reason": unsourceable_reason,
|
||||
"source_ref": f.get("source_ref", ""),
|
||||
**declared_as(f, fname),
|
||||
}
|
||||
self.unsourceable_list.append(row)
|
||||
self.set_records.append((keys, f, False, self.unsourceable_list, row))
|
||||
@@ -529,6 +542,10 @@ class _ProfileComparison:
|
||||
# The archive's own declaration names its sets: an archive
|
||||
# is a member like a loose file (Kronos' stvbios.zip).
|
||||
own = archive_entry(archive, self.profile.get("files", []))
|
||||
# Without a declaration of its own, the archive is what its
|
||||
# members are.
|
||||
entry.update(declared_as(
|
||||
{**own, "category": own.get("category") or f.get("category")}, archive))
|
||||
self.set_records.append((
|
||||
set_keys((self.emu_name, is_standalone), own), own,
|
||||
entry["in_repo"], self.archive_rows, entry,
|
||||
@@ -578,6 +595,7 @@ class _ProfileComparison:
|
||||
"source": source,
|
||||
# What tells this file from a homonym another emulator wants.
|
||||
"identity": first_hash(f),
|
||||
**declared_as(f, fname),
|
||||
}
|
||||
if save_root:
|
||||
entry["root"] = "save"
|
||||
@@ -761,6 +779,8 @@ def _settle_launcher_places(
|
||||
"identity": entry.get("sha1") or "",
|
||||
"launcher": entry["launcher"],
|
||||
"launcher_of": entry["launcher_of"],
|
||||
# The entry the launcher's name stands for, under that name.
|
||||
**declared_as(entry, entry["path"]),
|
||||
})
|
||||
for data in report.values():
|
||||
data.update(_gap_counts(data["gap_details"]))
|
||||
|
||||
@@ -236,7 +236,6 @@ def _emulator_export_items(profiles: dict) -> list[dict]:
|
||||
|
||||
def _gap_export_rows(
|
||||
coverages: dict, gap_report: dict | None = None, db: dict | None = None,
|
||||
profiles: dict | None = None,
|
||||
) -> list[dict]:
|
||||
"""Every gap the site reports, both layers, in one table.
|
||||
|
||||
@@ -272,10 +271,11 @@ def _gap_export_rows(
|
||||
})
|
||||
for emu_key, data in sorted((gap_report or {}).items()):
|
||||
systems = ";".join(str(s) for s in data.get("systems", []) or [])
|
||||
categories = _profile_categories((profiles or {}).get(emu_key) or {})
|
||||
# The category travels on the row: its path is the destination the
|
||||
# running build reads, not the profile's, and a join on it left 940
|
||||
# rows without one.
|
||||
rows.extend({
|
||||
"category": categories.get(
|
||||
(gap.get("name", ""), gap.get("path") or gap.get("name", "")), ""),
|
||||
"category": gap.get("category", ""),
|
||||
"collection_path": "",
|
||||
"resolved_sha1": "",
|
||||
"layer": "emulator",
|
||||
@@ -300,8 +300,7 @@ def _gap_export_rows(
|
||||
"expected": gap.get("identity", ""),
|
||||
} for gap in data.get("gap_details", []) or [])
|
||||
rows.extend({
|
||||
"category": categories.get(
|
||||
(entry.get("name", ""), entry.get("path") or entry.get("name", "")), ""),
|
||||
"category": entry.get("category", ""),
|
||||
"collection_path": "",
|
||||
"resolved_sha1": "",
|
||||
"layer": "emulator",
|
||||
@@ -326,17 +325,6 @@ def _gap_export_rows(
|
||||
return list(unique.values())
|
||||
|
||||
|
||||
def _profile_categories(profile: dict) -> dict[tuple[str, str], str]:
|
||||
"""(name, path) -> the category a profile gives the entry, bios by default."""
|
||||
found: dict[tuple[str, str], str] = {}
|
||||
for entry in profile.get("files") or []:
|
||||
if isinstance(entry, dict) and entry.get("name"):
|
||||
name = str(entry["name"])
|
||||
found.setdefault((name, str(entry.get("path") or name)),
|
||||
str(entry.get("category") or "bios"))
|
||||
return found
|
||||
|
||||
|
||||
def _cross_reference_export_rows(coverages: dict, profiles: dict) -> list[dict]:
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
@@ -640,7 +628,7 @@ def generate_data_exports(
|
||||
stamp = {"commit": commit} if commit else {}
|
||||
platform_items, platform_files = _platform_export_rows(coverages, db)
|
||||
emulator_items = _emulator_export_items(profiles)
|
||||
gap_rows = _gap_export_rows(coverages, gap_report, db, profiles)
|
||||
gap_rows = _gap_export_rows(coverages, gap_report, db)
|
||||
cross_rows = _cross_reference_export_rows(coverages, profiles)
|
||||
|
||||
members = data_directory_members()
|
||||
|
||||
@@ -530,6 +530,7 @@ def _missing_files(emulator_gaps: list[tuple[str, dict]]) -> _MissingFiles:
|
||||
"name": g["name"],
|
||||
"path": g.get("path") or g["name"],
|
||||
"identity": g.get("identity", ""),
|
||||
"profile_path": g.get("profile_path", ""),
|
||||
"emulators": [data["emulator"]],
|
||||
"emu_keys": [emu_name],
|
||||
"required": g["required"],
|
||||
@@ -577,7 +578,7 @@ def _source_row(m: dict, profiles: dict, placer: sitewanted.Placer | None) -> st
|
||||
for display, key in zip(m["emulators"], m["emu_keys"])
|
||||
)
|
||||
owner = profiles[m["emu_keys"][0]]
|
||||
declared = sitewanted.gap_entries(owner, m["name"], m["identity"], False)
|
||||
declared = sitewanted.gap_entries(owner, m, False)
|
||||
folder = placer.folder(declared[0]) if placer and declared else ""
|
||||
upload = sitewanted.upload_href(sitewanted.UPLOAD_ROOT, folder)
|
||||
return (
|
||||
@@ -752,7 +753,7 @@ def _not_collected_section(report_all: dict, profiles: dict, catalogued: dict |
|
||||
"source_ref": u.get("source_ref", ""),
|
||||
# The wanted page's own rule, on the entries behind the row.
|
||||
"wanted": any(sendable(entry, str(u["reason"])) for entry in sitewanted.gap_entries(
|
||||
profiles.get(emu_name) or {}, str(u["name"]), "", True)),
|
||||
profiles.get(emu_name) or {}, u, True)),
|
||||
}
|
||||
for emu_name, data in sorted(report_all.items())
|
||||
for u in data.get("unsourceable", [])
|
||||
|
||||
@@ -119,10 +119,19 @@ class Held:
|
||||
return False
|
||||
|
||||
|
||||
def gap_entries(profile: dict, name: str, identity: str, unsourceable: bool) -> list[dict]:
|
||||
"""The profile entries behind one row of the gap report."""
|
||||
def gap_entries(profile: dict, row: dict, unsourceable: bool) -> list[dict]:
|
||||
"""The profile entries behind one row of the gap report.
|
||||
|
||||
The row names the profile's own path (``profile_path``), which tells
|
||||
apart entries of one name the code reads in two places.
|
||||
"""
|
||||
name = str(row.get("name", ""))
|
||||
identity = str(row.get("identity") or "")
|
||||
declared = str(row.get("profile_path") or "")
|
||||
named = [f for f in profile.get("files") or []
|
||||
if isinstance(f, dict) and f.get("name") == name]
|
||||
if declared:
|
||||
named = [f for f in named if str(f.get("path") or name) == declared] or named
|
||||
if unsourceable:
|
||||
return [f for f in named if f.get("unsourceable")] or named
|
||||
if identity:
|
||||
@@ -230,8 +239,7 @@ def wanted_declarations(profiles: dict, coverages: dict, gap_report: dict) -> li
|
||||
rows += [(row, True) for row in data.get("unsourceable") or []]
|
||||
for row, unsourceable in rows:
|
||||
reason = str(row.get("reason") or "") if unsourceable else ""
|
||||
for entry in gap_entries(profile, str(row.get("name", "")),
|
||||
str(row.get("identity") or ""), unsourceable):
|
||||
for entry in gap_entries(profile, row, unsourceable):
|
||||
if not sendable(entry, reason):
|
||||
continue
|
||||
system = entry.get("system") or (systems[0] if len(systems) == 1 else "")
|
||||
|
||||
@@ -458,6 +458,33 @@ class TheGapsSayWhatToSupplyAndWhere(unittest.TestCase):
|
||||
self.assertEqual(row["expected"], "sha1:" + "a" * 40)
|
||||
|
||||
|
||||
class TheGapCategoryTravelsOnTheRow(unittest.TestCase):
|
||||
"""gaps.csv joined each row to its profile entry on the row's path, the
|
||||
destination the running build reads: 940 emulator rows had no category
|
||||
(a system_dir prefix, a standalone path, an unsourceable row without a
|
||||
path, an archive of members)."""
|
||||
|
||||
def test_every_row_carries_the_profile_category(self):
|
||||
from packs.crossref import cross_reference
|
||||
from sitegen.dataexports import _gap_export_rows
|
||||
|
||||
profiles = {"emu": {"emulator": "Emu", "systems": ["sys"], "files": [
|
||||
{"name": "a.bin", "path": "a.bin", "system_dir": "emu", "category": "game_data"},
|
||||
{"name": "b.o2r", "path": "emu/b.o2r", "category": "game_data",
|
||||
"unsourceable": "built by the user"},
|
||||
{"name": "m.rom", "archive": "set.zip", "category": "bios_zip"},
|
||||
]}}
|
||||
db = {"files": {}, "indexes": {"by_name": {}, "by_md5": {}, "by_crc32": {},
|
||||
"by_sha256": {}, "by_path_suffix": {}}}
|
||||
report = cross_reference(profiles, {}, db)
|
||||
rows = {r["name"]: r for r in _gap_export_rows({}, report)}
|
||||
self.assertEqual(rows["a.bin"]["destination"], "emu/a.bin")
|
||||
self.assertEqual(rows["a.bin"]["category"], "game_data")
|
||||
self.assertEqual(rows["b.o2r"]["category"], "game_data")
|
||||
self.assertEqual(rows["set.zip"]["category"], "bios_zip")
|
||||
self.assertNotIn("_profile_categories", script_source("generate_site.py"))
|
||||
|
||||
|
||||
|
||||
class AGoneSourceIsSaid(unittest.TestCase):
|
||||
"""citron, yuzu and suyu linked sources answering 451 or a domain now
|
||||
|
||||
Reference in new issue
Block a user