mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 05:18:51 -06:00
fix: pair gaps rows with the entry they score
This commit is contained in:
1 parent
a9d8e571c1
commit
a119efc149
4 files changed
+49
-31
No files matched your search
+27
-22
@@ -54,7 +54,7 @@ def _held_accepted(discrepancy: str, db: dict | None) -> str:
|
|||||||
_PROBLEM_HASHES = ("sha1", "md5", "sha256", "crc32")
|
_PROBLEM_HASHES = ("sha1", "md5", "sha256", "crc32")
|
||||||
|
|
||||||
|
|
||||||
def _declared_hashes(config: dict, detail: dict) -> dict[str, list[str]]:
|
def _declared_hashes(entry: dict) -> dict[str, list[str]]:
|
||||||
"""The hashes the platform declares for a reported file, by algorithm.
|
"""The hashes the platform declares for a reported file, by algorithm.
|
||||||
|
|
||||||
The untested table said "declared hash contradicted by the local file"
|
The untested table said "declared hash contradicted by the local file"
|
||||||
@@ -63,24 +63,27 @@ def _declared_hashes(config: dict, detail: dict) -> dict[str, list[str]]:
|
|||||||
"""
|
"""
|
||||||
from core.hashing import parse_hash_list
|
from core.hashing import parse_hash_list
|
||||||
|
|
||||||
system = (config.get("systems") or {}).get(detail.get("system", "")) or {}
|
return {
|
||||||
for entry in system.get("files") or []:
|
algo: parse_hash_list(entry.get(algo))
|
||||||
if isinstance(entry, dict) and entry.get("name") == detail.get("name"):
|
for algo in _PROBLEM_HASHES if parse_hash_list(entry.get(algo))
|
||||||
return {
|
}
|
||||||
algo: parse_hash_list(entry.get(algo))
|
|
||||||
for algo in _PROBLEM_HASHES if parse_hash_list(entry.get(algo))
|
|
||||||
}
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
def _declared_destination(config: dict, detail: dict) -> str:
|
def _declarations(cov: dict) -> dict[int, dict]:
|
||||||
"""Where the platform's list puts a reported file, its name when the
|
"""Each verify detail of a platform, by id, with the declaration it
|
||||||
entry names no folder."""
|
scores (wanted.paired_declarations): AmberELEC declares
|
||||||
system = (config.get("systems") or {}).get(detail.get("system", "")) or {}
|
hardwareconfig.xml under eighteen folders, and a match by name gave
|
||||||
for entry in system.get("files") or []:
|
every missing one the first folder."""
|
||||||
if isinstance(entry, dict) and entry.get("name") == detail.get("name"):
|
systems = (cov.get("config") or {}).get("systems") or {}
|
||||||
return str(entry.get("destination") or detail.get("name", ""))
|
by_system: dict[str, list[dict]] = {}
|
||||||
return str(detail.get("name", ""))
|
for detail in cov.get("details", []):
|
||||||
|
by_system.setdefault(detail.get("system", ""), []).append(detail)
|
||||||
|
return {
|
||||||
|
id(detail): entry
|
||||||
|
for system, details in by_system.items()
|
||||||
|
for detail, entry in sitewanted.paired_declarations(
|
||||||
|
(systems.get(system) or {}).get("files") or [], details)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def short_hash(value: str) -> str:
|
def short_hash(value: str) -> str:
|
||||||
@@ -405,9 +408,10 @@ def _by_platform_name(coverages: dict) -> list[tuple[str, dict]]:
|
|||||||
return sorted(coverages.items(), key=lambda x: x[1]["platform"])
|
return sorted(coverages.items(), key=lambda x: x[1]["platform"])
|
||||||
|
|
||||||
|
|
||||||
def _problem_record(pname: str, cov: dict, d: dict) -> dict:
|
def _problem_record(pname: str, cov: dict, d: dict, entry: dict) -> dict:
|
||||||
"""A detail of a platform's verify result that is not ok, as the
|
"""A detail of a platform's verify result that is not ok, as the
|
||||||
problem tables read it."""
|
problem tables read it, with the declaration it scores: the place the
|
||||||
|
list puts it, its name when the entry names no folder."""
|
||||||
return {
|
return {
|
||||||
"platform": cov["platform"],
|
"platform": cov["platform"],
|
||||||
"platform_key": pname,
|
"platform_key": pname,
|
||||||
@@ -418,8 +422,8 @@ def _problem_record(pname: str, cov: dict, d: dict) -> dict:
|
|||||||
"reason": d.get("reason", ""),
|
"reason": d.get("reason", ""),
|
||||||
"discrepancy": d.get("discrepancy", ""),
|
"discrepancy": d.get("discrepancy", ""),
|
||||||
"system": d.get("system", ""),
|
"system": d.get("system", ""),
|
||||||
"declared": _declared_hashes(cov.get("config") or {}, d),
|
"declared": _declared_hashes(entry),
|
||||||
"destination": _declared_destination(cov.get("config") or {}, d),
|
"destination": str(entry.get("destination") or d.get("name", "")),
|
||||||
"path": d.get("path") or "",
|
"path": d.get("path") or "",
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,6 +439,7 @@ def _verify_tally(coverages: dict) -> _VerifyTally:
|
|||||||
for category, count in (cov.get("missing_not_firmware") or {}).items():
|
for category, count in (cov.get("missing_not_firmware") or {}).items():
|
||||||
tally.not_firmware[category] = tally.not_firmware.get(category, 0) + count
|
tally.not_firmware[category] = tally.not_firmware.get(category, 0) + count
|
||||||
|
|
||||||
|
declarations = _declarations(cov)
|
||||||
for d in cov["details"]:
|
for d in cov["details"]:
|
||||||
if d.get("settled_by") and d["status"] != "ok":
|
if d.get("settled_by") and d["status"] != "ok":
|
||||||
# Its path holds another declaration's file: the headline,
|
# Its path holds another declaration's file: the headline,
|
||||||
@@ -446,7 +451,7 @@ def _verify_tally(coverages: dict) -> _VerifyTally:
|
|||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
if d["status"] != "ok" or d.get("discrepancy"):
|
if d["status"] != "ok" or d.get("discrepancy"):
|
||||||
tally.problems.append(_problem_record(pname, cov, d))
|
tally.problems.append(_problem_record(pname, cov, d, declarations.get(id(d), {})))
|
||||||
return tally
|
return tally
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ def _directory(entry: dict) -> str:
|
|||||||
return where.rsplit("/", 1)[0] + "/" if "/" in where else ""
|
return where.rsplit("/", 1)[0] + "/" if "/" in where else ""
|
||||||
|
|
||||||
|
|
||||||
def _paired(files: list, details: list[dict]) -> Iterable[tuple[dict, dict]]:
|
def paired_declarations(files: list, details: list[dict]) -> Iterable[tuple[dict, dict]]:
|
||||||
"""Each verify detail of a system with the declaration it scores.
|
"""Each verify detail of a system with the declaration it scores.
|
||||||
|
|
||||||
verify scores the declarations of a system in order, one detail each,
|
verify scores the declarations of a system in order, one detail each,
|
||||||
@@ -204,7 +204,7 @@ def wanted_declarations(profiles: dict, coverages: dict, gap_report: dict) -> li
|
|||||||
by_system.setdefault(detail.get("system", ""), []).append(detail)
|
by_system.setdefault(detail.get("system", ""), []).append(detail)
|
||||||
for system, details in sorted(by_system.items()):
|
for system, details in sorted(by_system.items()):
|
||||||
files = (systems.get(system) or {}).get("files") or []
|
files = (systems.get(system) or {}).get("files") or []
|
||||||
for detail, entry in _paired(files, details):
|
for detail, entry in paired_declarations(files, details):
|
||||||
if detail.get("settled_by") or detail.get("status") not in ("missing", "untested"):
|
if detail.get("settled_by") or detail.get("status") not in ("missing", "untested"):
|
||||||
continue
|
continue
|
||||||
if detail.get("category") == GAME_DATA or _brought_by_readers(
|
if detail.get("category") == GAME_DATA or _brought_by_readers(
|
||||||
|
|||||||
@@ -5589,12 +5589,27 @@ class GapsPageCountsOneWay(unittest.TestCase):
|
|||||||
"`bios/quasi88/N88_KNJ1.ROM` |", text)
|
"`bios/quasi88/N88_KNJ1.ROM` |", text)
|
||||||
|
|
||||||
def test_the_destination_is_the_list_entrys(self):
|
def test_the_destination_is_the_list_entrys(self):
|
||||||
from scripts.sitegen.gaps import _declared_destination
|
"""AmberELEC declares hardwareconfig.xml under eighteen MSX folders:
|
||||||
|
each missing one is shown under its own, not under the first."""
|
||||||
|
from scripts.sitegen.gaps import _verify_tally
|
||||||
from model.platforms import load_platform_config
|
from model.platforms import load_platform_config
|
||||||
|
|
||||||
config = load_platform_config("amberelec", str(ROOT / "platforms"))
|
config = load_platform_config("amberelec", str(ROOT / "platforms"))
|
||||||
detail = {"name": "N88_KNJ1.ROM", "system": "nec-pc-88"}
|
details, wanted = [], []
|
||||||
self.assertEqual(_declared_destination(config, detail), "bios/quasi88/N88_KNJ1.ROM")
|
for system, data in (config.get("systems") or {}).items():
|
||||||
|
for entry in data.get("files") or []:
|
||||||
|
missing = entry["name"] in ("hardwareconfig.xml", "N88_KNJ1.ROM")
|
||||||
|
details.append({"name": entry["name"], "system": system,
|
||||||
|
"status": "missing" if missing else "ok"})
|
||||||
|
if missing:
|
||||||
|
wanted.append(str(entry.get("destination") or entry["name"]))
|
||||||
|
coverage = {"platform": "AmberELEC", "config": config, "details": details,
|
||||||
|
"verified": 0, "untested": 0, "missing": len(wanted), "total": len(details)}
|
||||||
|
tally = _verify_tally({"amberelec": coverage})
|
||||||
|
shown = [p["destination"] for p in tally.problems]
|
||||||
|
self.assertEqual(shown, wanted)
|
||||||
|
self.assertGreater(len(set(shown)), 2)
|
||||||
|
self.assertIn("bios/quasi88/N88_KNJ1.ROM", shown)
|
||||||
|
|
||||||
def test_verify_marks_the_settled_entry(self):
|
def test_verify_marks_the_settled_entry(self):
|
||||||
from packs import coverage as packs_coverage
|
from packs import coverage as packs_coverage
|
||||||
|
|||||||
@@ -55,13 +55,11 @@ class AnUntestedRowNamesBothHashes(unittest.TestCase):
|
|||||||
|
|
||||||
path = "bios/Nintendo/Nintendo DS/dsifirmware.bin"
|
path = "bios/Nintendo/Nintendo DS/dsifirmware.bin"
|
||||||
declared, held = "1" * 64, "2" * 64
|
declared, held = "1" * 64, "2" * 64
|
||||||
config = {"systems": {"nintendo-ds": {"files": [
|
entry = {"name": "dsifirmware.bin", "sha256": declared}
|
||||||
{"name": "dsifirmware.bin", "sha256": declared}]}}}
|
|
||||||
detail = {"name": "dsifirmware.bin", "system": "nintendo-ds"}
|
|
||||||
problem = {
|
problem = {
|
||||||
"platform": "RetroDECK", "name": "dsifirmware.bin", "status": "untested",
|
"platform": "RetroDECK", "name": "dsifirmware.bin", "status": "untested",
|
||||||
"required": True, "reason": "declared hash contradicted by the local file",
|
"required": True, "reason": "declared hash contradicted by the local file",
|
||||||
"declared": gaps._declared_hashes(config, detail), "path": path,
|
"declared": gaps._declared_hashes(entry), "path": path,
|
||||||
}
|
}
|
||||||
db = {"files": {"f" * 40: {"path": path, "sha256": held}}}
|
db = {"files": {"f" * 40: {"path": path, "sha256": held}}}
|
||||||
table = "\n".join(gaps._render_problem_files([problem], db=db))
|
table = "\n".join(gaps._render_problem_files([problem], db=db))
|
||||||
|
|||||||
Reference in new issue
Block a user