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

+4 -11
View File
@@ -16,7 +16,7 @@ from core.paths import REPO_ROOT
from sitegen.descriptions import EMULATOR_SNIPPETS, NOTHING_TO_FETCH, PAGE_DATA, TITLE_NOUNS, title_noun
from sitegen.emulatorcards import snippet_noun
from sitegen.install import comes_with_app
from sitegen.lookup import data_member_digests, sorted_hash_values
from sitegen.lookup import data_member_digests, hash_pairs
from sitegen.render import card_anchor, system_page_map
from sitegen.write import write_if_changed
@@ -197,8 +197,7 @@ def platform_structured_data(name: str, coverage: dict) -> dict:
}
identifiers = [
f"{field}:{value}"
for field in ("sha1", "md5", "crc32", "sha256")
for value in sorted_hash_values(entry.get(field))
for field, value in hash_pairs(entry, ("sha1", "md5", "crc32", "sha256"))
]
if identifiers:
part["identifier"] = identifiers
@@ -369,11 +368,7 @@ def emulator_structured_data(profile: dict) -> dict:
continue
# One identifier per accepted value: "sha256:a,b,c,d" matched no
# exact search (mesence's BS-X.bin).
identifiers = [
f"{field}:{value}"
for field in ("sha1", "sha256", "md5", "crc32")
for value in sorted_hash_values(f.get(field))
]
identifiers = [f"{field}:{value}" for field, value in hash_pairs(f)]
part: dict[str, object] = {
"@type": "CreativeWork",
"name": str(f.get("path") or f["name"]),
@@ -389,9 +384,7 @@ def emulator_structured_data(profile: dict) -> dict:
"@type": "CreativeWork",
"name": str(member.get("name", "")),
"identifier": [
f"{field}:{value}"
for field in ("sha1", "crc32")
for value in sorted_hash_values(member.get(field))
f"{field}:{value}" for field, value in hash_pairs(member, ("sha1", "crc32"))
],
}
for member in f.get("contents") or []