mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 22:38:54 -06:00
fix: gaps and wanted read one sendable rule
This commit is contained in:
1 parent
7ad22248b5
commit
2ccd7bb88f
6 files changed
+120
-64
No files matched your search
@@ -16,7 +16,6 @@ the review of the pull request asks for that same folder.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import urllib.parse
|
||||
from collections.abc import Callable, Iterable
|
||||
from pathlib import Path
|
||||
@@ -28,7 +27,8 @@ from model.profiles import unique_emulator_profiles
|
||||
from packs.crossref import first_hash
|
||||
from core.hashing import cut_md5_owner, declared_hash_lists, parse_hash_list
|
||||
from resolve.review import LARGE_FILE_ISSUE_URL, Placement, placement
|
||||
from resolve.validation import deliverable, filter_files_by_mode, installed_everywhere
|
||||
from resolve.sendable import can_send, sendable
|
||||
from resolve.validation import deliverable, filter_files_by_mode
|
||||
from sitegen.config import UPLOAD_ROOT
|
||||
|
||||
ALGORITHMS = ("sha1", "sha256", "md5", "crc32")
|
||||
@@ -229,73 +229,29 @@ def wanted_declarations(profiles: dict, coverages: dict, gap_report: dict) -> li
|
||||
if gap.get("source") == "missing" and not gap.get("bundled")]
|
||||
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):
|
||||
if entry.get("category") == GAME_DATA or installed_everywhere(entry):
|
||||
if not sendable(entry, reason):
|
||||
continue
|
||||
system = entry.get("system") or (systems[0] if len(systems) == 1 else "")
|
||||
found.append({
|
||||
"name": str(entry["name"]), "system": str(system),
|
||||
"required": bool(row.get("required", False)),
|
||||
"reader": ("emulator", key, str(data.get("emulator", key))), "entry": entry,
|
||||
"reason": str(row.get("reason") or "") if unsourceable else "",
|
||||
"reason": reason,
|
||||
"category": BIOS,
|
||||
"directory": _directory(entry),
|
||||
})
|
||||
return found
|
||||
|
||||
|
||||
def catalog_listings(report: dict | None, labels: dict[str, str]) -> dict[tuple[str, str], list[tuple[str, str]]]:
|
||||
"""(profile, file name casefolded) -> (catalog or romset, the name it
|
||||
lists the file under), from a provenance report built with the
|
||||
profiles' needs: the "Listed in" column of the gaps page."""
|
||||
out: dict[tuple[str, str], list[tuple[str, str]]] = {}
|
||||
for source, data in sorted((report or {}).items()):
|
||||
label = labels.get(source, source)
|
||||
for entry in data.get("missing", []):
|
||||
where = [(label, str(entry.get("name", "")))]
|
||||
where += [(str(hit["source"]), str(hit["archive"])) for hit in entry.get("romsets", [])]
|
||||
for need in entry.get("needed_by", []):
|
||||
held = out.setdefault((need["emulator"], str(need["name"]).casefold()), [])
|
||||
held += [w for w in where if w not in held]
|
||||
return out
|
||||
|
||||
|
||||
BIOS = "bios"
|
||||
GAME_DATA = "game_data"
|
||||
# verify's category for a platform entry no core the platform runs reads.
|
||||
UNREAD = "unread"
|
||||
# Firmware first, then what a platform lists and no core reads.
|
||||
RANK = {BIOS: 0, UNREAD: 1}
|
||||
# A name the code builds from the content (<serial>.txt, *.ini) is a
|
||||
# pattern, not a file anyone can upload.
|
||||
PATTERN = re.compile(r"[<>*?]")
|
||||
# A file not collected yet stays wanted, however hard it is to find ("no
|
||||
# public dump located", "retail data the collection does not hold"). It
|
||||
# leaves the list only when its reason (the profile's `unsourceable:`)
|
||||
# says no copy can be shared, read by the rules below.
|
||||
NOT_SHAREABLE = re.compile("|".join([
|
||||
# Any file of the name serves: there is no one file to collect.
|
||||
r"\bno canonical\b",
|
||||
# The user writes, picks, records or places it (WHDLoad's key aside,
|
||||
# emucorev's config.txt: "plugin list the user writes").
|
||||
r"\bthe user\b|\buser[- ](?:supplied|authored|created|settings|overlay|placeholder)\b"
|
||||
r"|\bother users\b",
|
||||
# The emulator or the guest writes it: a save, a state, a generated key.
|
||||
r"\bwritten by (?:the (?:emulator|guest|firmware editor)|bam)\b|\bgenerated by the emulator\b"
|
||||
r"|\bwith the debug key\b|\bmachine state\b|\bcreat\w* (?:this directory )?empty\b",
|
||||
# It belongs to one person, one account or one copy (puae's WHDLoad.key).
|
||||
r"\bper[- ]user\b|\btied to the (?:account|tag)\b|\bnever distributed generically\b"
|
||||
r"|\bissued for one copy\b",
|
||||
# Nothing was ever released under the name.
|
||||
r"\bno (?:distributed form|released artefact|hardware dump equivalent)\b"
|
||||
r"|\bno file of this name is distributed\b",
|
||||
]), re.I)
|
||||
|
||||
|
||||
def shareable(reason: str) -> bool:
|
||||
"""False when a reason says no copy of the file can be shared."""
|
||||
return not NOT_SHAREABLE.search(reason)
|
||||
|
||||
|
||||
def _settle_cut(records: list[dict]) -> None:
|
||||
@@ -444,7 +400,7 @@ def _collect_records(declarations: Iterable[dict], held: Held,
|
||||
share are left out."""
|
||||
records: dict[tuple, dict] = {}
|
||||
for declaration in declarations:
|
||||
if PATTERN.search(declaration["name"]) or not shareable(declaration["reason"]):
|
||||
if not can_send(declaration["name"], declaration["reason"]):
|
||||
continue
|
||||
entry = declaration["entry"]
|
||||
sizes = _sizes(entry)
|
||||
|
||||
Reference in new issue
Block a user