mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-30 21:38:55 -06:00
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:
1 parent
ea68e85c06
commit
02969dda06
30 files changed
+176
-195
No files matched your search
@@ -28,7 +28,7 @@ from core.paths import REPO_ROOT
|
||||
from sitegen.install import release_pack_platforms
|
||||
from sitegen.lookup import (
|
||||
HASH_ALGORITHMS,
|
||||
sorted_hash_values,
|
||||
hash_pairs,
|
||||
data_directory_members,
|
||||
file_location_items,
|
||||
file_lookup_records,
|
||||
@@ -48,23 +48,23 @@ def _accepted_hash_rows(platform_files: list[dict], emulator_items: list[dict])
|
||||
"""One row per accepted hash value, for both layers, lookup-ready."""
|
||||
rows: list[dict] = []
|
||||
for row in platform_files:
|
||||
for algorithm in HASH_ALGORITHMS:
|
||||
rows.extend({
|
||||
"layer": "platform", "owner": row["platform_id"],
|
||||
"system": row["system"], "name": row["name"],
|
||||
"path": row["destination"], "algorithm": algorithm, "value": value,
|
||||
} for value in sorted_hash_values(row.get(f"{algorithm}_raw", row.get(algorithm))))
|
||||
# A table row keeps the field as declared under <algorithm>_raw.
|
||||
declared = {algo: row.get(f"{algo}_raw", row.get(algo)) for algo in HASH_ALGORITHMS}
|
||||
rows.extend({
|
||||
"layer": "platform", "owner": row["platform_id"],
|
||||
"system": row["system"], "name": row["name"],
|
||||
"path": row["destination"], "algorithm": algorithm, "value": value,
|
||||
} for algorithm, value in hash_pairs(declared))
|
||||
for item in emulator_items:
|
||||
for entry in item["profile"].get("files", []) or []:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
for algorithm in HASH_ALGORITHMS:
|
||||
rows.extend({
|
||||
"layer": "emulator", "owner": item["id"],
|
||||
"system": _json_text(entry.get("system")),
|
||||
"name": entry.get("name", ""), "path": entry.get("path", "") or "",
|
||||
"algorithm": algorithm, "value": value,
|
||||
} for value in sorted_hash_values(entry.get(algorithm)))
|
||||
rows.extend({
|
||||
"layer": "emulator", "owner": item["id"],
|
||||
"system": _json_text(entry.get("system")),
|
||||
"name": entry.get("name", ""), "path": entry.get("path", "") or "",
|
||||
"algorithm": algorithm, "value": value,
|
||||
} for algorithm, value in hash_pairs(entry))
|
||||
# Members of an archive: MAME and FBNeo hash the ROMs inside the
|
||||
# set, never the set. Left out, a loose nmk004.bin (crc32
|
||||
# 83b6f611) found no row while the site search found it.
|
||||
@@ -72,13 +72,12 @@ def _accepted_hash_rows(platform_files: list[dict], emulator_items: list[dict])
|
||||
for member in entry.get("contents") or []:
|
||||
if not isinstance(member, dict) or not member.get("name"):
|
||||
continue
|
||||
for algorithm in HASH_ALGORITHMS:
|
||||
rows.extend({
|
||||
"layer": "emulator", "owner": item["id"],
|
||||
"system": _json_text(entry.get("system")),
|
||||
"name": str(member["name"]), "path": f"{archive}/{member['name']}",
|
||||
"algorithm": algorithm, "value": value,
|
||||
} for value in sorted_hash_values(member.get(algorithm)))
|
||||
rows.extend({
|
||||
"layer": "emulator", "owner": item["id"],
|
||||
"system": _json_text(entry.get("system")),
|
||||
"name": str(member["name"]), "path": f"{archive}/{member['name']}",
|
||||
"algorithm": algorithm, "value": value,
|
||||
} for algorithm, value in hash_pairs(member))
|
||||
rows.sort(key=lambda r: (r["layer"], r["owner"], r["name"], r["algorithm"], r["value"]))
|
||||
return rows
|
||||
|
||||
|
||||
Reference in new issue
Block a user