refactor: read declared hashes with one helper

core.hashing.declared_hash_lists gives an entry's declared values per
field in the order written, and declared_hashes builds its sets on it.
The gap page, the doubled-destination report and the file lookup used
their own copies of that reader. The wanted page keeps its filters on
top of it. sitegen.lookup.hash_pairs replaces sorted_hash_values for
the lookup, the data exports and the structured data. The one-field
aliases parse_md5_list and reconcile.hash_values are gone, and
model.profiles reads HASH_FIELDS instead of a fourth tuple.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 10:29:37 +01:00
1 parent ea68e85c06
commit 02969dda06
30 files changed
+176 -195

No files matched your search

+5 -19
View File
@@ -7,6 +7,7 @@ import html
import re
from dataclasses import dataclass
from core.hashing import declared_hash_lists
from core.text import series
from model.platforms import native_layer
from model.profiles import is_emulator
@@ -51,24 +52,6 @@ def _held_accepted(discrepancy: str, db: dict | None) -> str:
return ""
_PROBLEM_HASHES = ("sha1", "md5", "sha256", "crc32")
def _declared_hashes(entry: dict) -> dict[str, list[str]]:
"""The hashes the platform declares for a reported file, by algorithm.
The untested table said "declared hash contradicted by the local file"
and named neither: the reader could not look for the dump RetroDECK asks
for, nor report the difference.
"""
from core.hashing import parse_hash_list
return {
algo: parse_hash_list(entry.get(algo))
for algo in _PROBLEM_HASHES if parse_hash_list(entry.get(algo))
}
def _declarations(cov: dict) -> dict[int, dict]:
"""Each verify detail of a platform, by id, with the declaration it
scores (wanted.paired_declarations): AmberELEC declares
@@ -422,7 +405,10 @@ def _problem_record(pname: str, cov: dict, d: dict, entry: dict) -> dict:
"reason": d.get("reason", ""),
"discrepancy": d.get("discrepancy", ""),
"system": d.get("system", ""),
"declared": _declared_hashes(entry),
# The untested table said "declared hash contradicted by the local
# file" and named neither: the reader could not look for the dump
# RetroDECK asks for, nor report the difference.
"declared": declared_hash_lists(entry),
"destination": str(entry.get("destination") or d.get("name", "")),
"path": d.get("path") or "",
}