mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
feat: rank unread platform files after firmware
A file a platform lists and no core it runs reads (verify's unread category) comes after firmware and before game data, labelled on its row.
This commit is contained in:
1 parent
8ae4cb61ac
commit
6ce6469d25
4 files changed
+36
-25
No files matched your search
+19
-13
@@ -180,7 +180,7 @@ def wanted_declarations(profiles: dict, coverages: dict, gap_report: dict) -> li
|
||||
"required": bool(detail.get("required", True)),
|
||||
"reader": ("platform", key, coverage["platform"]), "entry": entry,
|
||||
"reason": "",
|
||||
"category": GAME_DATA if detail.get("category") == GAME_DATA else BIOS,
|
||||
"category": detail.get("category") if detail.get("category") in RANK else BIOS,
|
||||
"directory": _directory(entry),
|
||||
})
|
||||
unique = unique_emulator_profiles(profiles)
|
||||
@@ -225,6 +225,11 @@ def catalog_listings(report: dict | None, labels: dict[str, str]) -> dict[tuple[
|
||||
|
||||
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, then game
|
||||
# data. The value is also the list's k field, absent for firmware.
|
||||
RANK = {BIOS: 0, UNREAD: 1, GAME_DATA: 2}
|
||||
# A name the code builds from the content (<serial>.txt, *.ini) is a
|
||||
# pattern, not a file anyone can upload.
|
||||
PATTERN = re.compile(r"[<>*?]")
|
||||
@@ -342,10 +347,10 @@ def upload_href(root: str, folder: str) -> str:
|
||||
|
||||
|
||||
def _order(record: dict) -> tuple:
|
||||
"""Most useful first: required firmware, optional firmware, then game
|
||||
data, required first, and within each by how many setups and
|
||||
emulators read the file."""
|
||||
return (record["category"] != BIOS, not record["required"], -len(record["readers"]),
|
||||
"""Most useful first: required firmware, optional firmware, then the
|
||||
files no core reads, then game data, required first, and within each
|
||||
by how many setups and emulators read the file."""
|
||||
return (RANK[record["category"]], not record["required"], -len(record["readers"]),
|
||||
record["name"].casefold(), sorted(record["readers"]))
|
||||
|
||||
|
||||
@@ -364,7 +369,8 @@ def build_wanted(
|
||||
Readers, systems and folders are written once and named by position.
|
||||
An entry: n name, h hashes (absent when the declarations write none:
|
||||
the file is known by its name only), w readers, s systems, r required,
|
||||
z sizes, g game data (firmware when absent), d what the file is, u why
|
||||
z sizes, k 1 when no core reads it and 2 for game data (firmware when
|
||||
absent), d what the file is, u why
|
||||
it is not collected yet, l the catalogs that list it with the name
|
||||
they give it, f folder, t the name it is uploaded under, v that name
|
||||
goes to the folder's .variants/ with the first 8 characters of its
|
||||
@@ -391,8 +397,8 @@ def build_wanted(
|
||||
"description": "", "reason": "", "listed": [], "category": GAME_DATA,
|
||||
"directory": declaration["directory"],
|
||||
})
|
||||
if declaration["category"] == BIOS:
|
||||
record["category"] = BIOS
|
||||
if RANK[declaration["category"]] < RANK[record["category"]]:
|
||||
record["category"] = declaration["category"]
|
||||
if declaration["system"]:
|
||||
record["systems"].add(declaration["system"])
|
||||
record["required"] = record["required"] or declaration["required"]
|
||||
@@ -434,8 +440,8 @@ def build_wanted(
|
||||
item["r"] = 1
|
||||
if record["sizes"]:
|
||||
item["z"] = record["sizes"]
|
||||
if record["category"] == GAME_DATA:
|
||||
item["g"] = 1
|
||||
if RANK[record["category"]]:
|
||||
item["k"] = RANK[record["category"]]
|
||||
for field, value in (("d", record["description"]), ("u", record["reason"])):
|
||||
if value:
|
||||
item[field] = value
|
||||
@@ -478,8 +484,8 @@ def _merge_named(records: dict[tuple, dict]) -> None:
|
||||
target["required"] = target["required"] or record["required"]
|
||||
target["description"] = target["description"] or record["description"]
|
||||
target["reason"] = target["reason"] or record["reason"]
|
||||
if record["category"] == BIOS:
|
||||
target["category"] = BIOS
|
||||
if RANK[record["category"]] < RANK[target["category"]]:
|
||||
target["category"] = record["category"]
|
||||
target["listed"] += [w for w in record["listed"] if w not in target["listed"]]
|
||||
|
||||
|
||||
@@ -533,7 +539,7 @@ def page(total: int, known: int) -> str:
|
||||
"",
|
||||
"## The wanted list",
|
||||
"",
|
||||
(f"The list holds {total:,} files, firmware first, then game data. Of these, {known:,} have a "
|
||||
(f"The list holds {total:,} files, firmware first and game data last. Of these, {known:,} have a "
|
||||
"fingerprint (a hash), so a dropped copy is recognised."),
|
||||
"",
|
||||
"The others are known by name only: upload one and the check decides.",
|
||||
|
||||
+15
-10
@@ -147,7 +147,8 @@ class _World(unittest.TestCase):
|
||||
"platform": "Plat", "config": {"systems": platform},
|
||||
"details": [
|
||||
{"name": "v.bin", "status": "untested", "system": "x", "required": True},
|
||||
{"name": "cut.bin", "status": "missing", "system": "x", "required": False},
|
||||
{"name": "cut.bin", "status": "missing", "system": "x", "required": False,
|
||||
"category": "unread"},
|
||||
{"name": "z.zip", "status": "missing", "system": "x", "required": True},
|
||||
{"name": "r.bin", "status": "missing", "system": "x", "required": True},
|
||||
{"name": "a.bin", "status": "ok", "system": "x"},
|
||||
@@ -191,14 +192,16 @@ class TheListHoldsWhatTheGapsReportLacks(_World):
|
||||
self.assertIn("h", self.entry("b.bin"))
|
||||
|
||||
def test_required_entries_come_first(self):
|
||||
firmware = [e for e in self.data["entries"] if not e.get("g")]
|
||||
firmware = [e for e in self.data["entries"] if not e.get("k")]
|
||||
needs = [bool(e.get("r")) for e in firmware]
|
||||
self.assertEqual(needs, sorted(needs, reverse=True))
|
||||
self.assertTrue(any(needs) and not all(needs))
|
||||
|
||||
def test_firmware_comes_before_game_data(self):
|
||||
games = [bool(e.get("g")) for e in self.data["entries"]]
|
||||
self.assertEqual(games, sorted(games))
|
||||
kinds = [e.get("k", 0) for e in self.data["entries"]]
|
||||
self.assertEqual(kinds, sorted(kinds))
|
||||
self.assertEqual(self.entry("g.bin")["k"], 2)
|
||||
self.assertEqual(self.entry("cut.bin")["k"], 1)
|
||||
# g.bin is required, and still after every optional firmware file.
|
||||
self.assertEqual(self.data["entries"][-1]["n"], "g.bin")
|
||||
self.assertEqual(self.entry("g.bin").get("r"), 1)
|
||||
@@ -231,11 +234,13 @@ class TheListHoldsWhatTheGapsReportLacks(_World):
|
||||
"readers": {("emulator", "e", "E"), ("platform", "p", "P")}},
|
||||
{"name": "c", "required": True, "readers": {("emulator", "e", "E")}},
|
||||
{"name": "d", "required": True, "readers": {("emulator", "e", "E")},
|
||||
"category": sitewanted.GAME_DATA}]
|
||||
"category": sitewanted.GAME_DATA},
|
||||
{"name": "u", "required": True, "readers": {("platform", "p", "P")},
|
||||
"category": sitewanted.UNREAD}]
|
||||
for record in records:
|
||||
record.setdefault("category", sitewanted.BIOS)
|
||||
self.assertEqual([r["name"] for r in sorted(records, key=sitewanted._order)],
|
||||
["c", "b", "a", "d"])
|
||||
["c", "b", "a", "u", "d"])
|
||||
|
||||
def test_a_name_with_no_hash_joins_the_hashed_entry_of_its_name(self):
|
||||
reader = ("emulator", "other", "Other")
|
||||
@@ -576,10 +581,10 @@ class ThePublishedList(unittest.TestCase):
|
||||
self.assertFalse(held.holds(entry["h"], entry.get("z", [])))
|
||||
|
||||
def test_firmware_first_then_required_first(self):
|
||||
games = [bool(e.get("g")) for e in self.data["entries"]]
|
||||
self.assertEqual(games, sorted(games))
|
||||
for game in (False, True):
|
||||
needs = [bool(e.get("r")) for e in self.data["entries"] if bool(e.get("g")) == game]
|
||||
kinds = [e.get("k", 0) for e in self.data["entries"]]
|
||||
self.assertEqual(kinds, sorted(kinds))
|
||||
for kind in (0, 1, 2):
|
||||
needs = [bool(e.get("r")) for e in self.data["entries"] if e.get("k", 0) == kind]
|
||||
self.assertEqual(needs, sorted(needs, reverse=True))
|
||||
self.assertTrue(any("h" not in e for e in self.data["entries"]))
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ const version = wantedVersion();
|
||||
const head = element('p', code(entry.n), ' ');
|
||||
const need = element('span', entry.r ? 'Required' : 'Optional');
|
||||
need.className = `rb-badge ${entry.r ? 'rb-badge-warning' : 'rb-badge-muted'}`;
|
||||
const kind = element('span', entry.g ? 'Game data' : 'Firmware');
|
||||
const kind = element('span', entry.k === 2 ? 'Game data' : entry.k === 1 ? 'Read by no core' : 'Firmware');
|
||||
kind.className = 'rb-badge rb-badge-info';
|
||||
head.append(need, ' ', kind);
|
||||
if (entry.z?.length) head.append(` ${entry.z.map(size).join(' or ')}`);
|
||||
|
||||
@@ -12,7 +12,7 @@ export type Entry = {
|
||||
s?: number[];
|
||||
r?: number;
|
||||
z?: number[];
|
||||
g?: number;
|
||||
k?: number;
|
||||
d?: string;
|
||||
u?: string;
|
||||
l?: [string, string][];
|
||||
|
||||
Reference in new issue
Block a user