mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: name every export change on the site page
The run's summary and the exports page each built the sentence from their own table, and the page dropped sizes and hashes removed and md5 lists. Both now read one table of change kinds, and each report stores a count per kind. The committed reports gain those counts from their own records.
This commit is contained in:
1 parent
74c59ad3b9
commit
04e1d2d3ab
20 files changed
+227
-63
No files matched your search
@@ -50,6 +50,7 @@ on:
|
||||
- "scripts/model/database.py"
|
||||
- "scripts/model/declarations.py"
|
||||
- "scripts/model/dumpcatalog.py"
|
||||
- "scripts/model/exportchanges.py"
|
||||
- "scripts/model/guides.py"
|
||||
- "scripts/model/largefiles.py"
|
||||
- "scripts/model/mamerelease.py"
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 440,
|
||||
"added": 55,
|
||||
"not_added": 1917,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 10,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 692,
|
||||
"added": 172,
|
||||
"not_added": 2554,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 4,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 121,
|
||||
"added": 0,
|
||||
"not_added": 0,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [],
|
||||
"hashes_updated": [],
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 170,
|
||||
"added": 0,
|
||||
"not_added": 2334,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [],
|
||||
"hashes_updated": [],
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 590,
|
||||
"added": 37,
|
||||
"not_added": 1885,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 47,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
+8
-1
@@ -11,7 +11,14 @@
|
||||
"kept": 566,
|
||||
"added": 105,
|
||||
"not_added": 2051,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 4,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
+8
-1
@@ -11,7 +11,14 @@
|
||||
"kept": 519,
|
||||
"added": 202,
|
||||
"not_added": 1799,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 76,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 23,
|
||||
"size_removed": 1,
|
||||
"hash_cleared": 2,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,14 @@
|
||||
"kept": 88,
|
||||
"added": 0,
|
||||
"not_added": 0,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [],
|
||||
"hashes_updated": [],
|
||||
|
||||
@@ -12,7 +12,14 @@
|
||||
"kept": 357,
|
||||
"added": 90,
|
||||
"not_added": 522,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 2,
|
||||
"required_aligned": 131,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 1
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 519,
|
||||
"added": 213,
|
||||
"not_added": 1806,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 76,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 23,
|
||||
"size_removed": 1,
|
||||
"hash_cleared": 2,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -11,7 +11,14 @@
|
||||
"kept": 362,
|
||||
"added": 50,
|
||||
"not_added": 1931,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 1,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 9,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -29,7 +29,14 @@
|
||||
"kept": 2021,
|
||||
"added": 77,
|
||||
"not_added": 1269,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 0,
|
||||
"required_aligned": 41,
|
||||
"hash_filled": 118,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
@@ -12,7 +12,14 @@
|
||||
"kept": 38,
|
||||
"added": 6,
|
||||
"not_added": 1853,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 2,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
+8
-1
@@ -11,7 +11,14 @@
|
||||
"kept": 374,
|
||||
"added": 94,
|
||||
"not_added": 342,
|
||||
"not_kept": 0
|
||||
"not_kept": 0,
|
||||
"hash_updated": 1,
|
||||
"required_aligned": 0,
|
||||
"hash_filled": 0,
|
||||
"size_updated": 0,
|
||||
"size_removed": 0,
|
||||
"hash_cleared": 0,
|
||||
"md5_lists": 0
|
||||
},
|
||||
"changes": [
|
||||
{
|
||||
|
||||
+26
-27
@@ -21,6 +21,7 @@ from .doubled import doubled_destinations
|
||||
from .landed import LandedChanges, landed_changes
|
||||
from .originals import collect_originals, unpinned, wanted_sources
|
||||
from model.database import load_database
|
||||
from model.exportchanges import change_phrases
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.registry import load_data_dir_registry, load_platform_registry
|
||||
@@ -249,9 +250,10 @@ def build_export(
|
||||
landed, refused, lost = _entry_outcomes(exporter, systems)
|
||||
|
||||
own_summary = exporter.outcome(systems, produced)
|
||||
counts = _change_counts(report, changes, landed, refused, lost)
|
||||
summary = own_summary
|
||||
if summary is None:
|
||||
summary = _landed_summary(report, changes, landed, lost)
|
||||
summary = _landed_summary(counts)
|
||||
withheld = exporter.withheld()
|
||||
unwritten = _unwritten(refused, withheld, report)
|
||||
# Reported, never removed: the platform's file keeps every entry.
|
||||
@@ -267,12 +269,7 @@ def build_export(
|
||||
"originals": wanted_sources(exporter, systems, scraped),
|
||||
"files": sorted(produced),
|
||||
"summary": summary,
|
||||
"counts": None if own_summary is not None else {
|
||||
"kept": report.files_kept,
|
||||
"added": landed,
|
||||
"not_added": refused,
|
||||
"not_kept": lost,
|
||||
},
|
||||
"counts": None if own_summary is not None else counts,
|
||||
"changes": changes.records,
|
||||
"hashes_updated": applied,
|
||||
"hashes_filled": filled,
|
||||
@@ -349,27 +346,29 @@ def _entry_outcomes(exporter: BaseExporter, systems: dict) -> tuple[int, int, in
|
||||
return landed, refused, lost
|
||||
|
||||
|
||||
def _landed_summary(report: Report, changes: LandedChanges, landed: int, lost: int) -> str:
|
||||
# What the written file carries, in the terms the exports page uses.
|
||||
def _change_counts(
|
||||
report: Report, changes: LandedChanges, landed: int, refused: int, lost: int
|
||||
) -> dict[str, int]:
|
||||
"""How many entries each kind of change touches, as the report stores them."""
|
||||
return {
|
||||
"kept": report.files_kept,
|
||||
"added": landed,
|
||||
"not_added": refused,
|
||||
"not_kept": lost,
|
||||
"hash_updated": len(changes.applied),
|
||||
"required_aligned": changes.requirements,
|
||||
"hash_filled": len(changes.filled),
|
||||
"size_updated": len(changes.resized),
|
||||
"size_removed": len(changes.unsized),
|
||||
"hash_cleared": len(changes.cleared),
|
||||
"md5_lists": changes.lists,
|
||||
}
|
||||
|
||||
|
||||
def _landed_summary(counts: dict[str, int]) -> str:
|
||||
# What the written file carries, the same changes the exports page names.
|
||||
# What it does not carry is counted on a line of its own below.
|
||||
parts = [f"{report.files_kept} kept"]
|
||||
landed_counts = (
|
||||
(landed, "file", "", "added"),
|
||||
(len(changes.applied), "hash", "", "updated to the emulator source"),
|
||||
(changes.requirements, "required flag", "", "aligned with the code"),
|
||||
(len(changes.filled), "hash", "", "added to an existing entry"),
|
||||
(len(changes.resized), "size", "", "updated to the emulator source"),
|
||||
(len(changes.unsized), "size", "", "removed"),
|
||||
(len(changes.cleared), "hash", "", "removed"),
|
||||
(lost, "entry", "entries", "removed, the format cannot state them"),
|
||||
(changes.lists, "md5 list", "", "written, any listed value passes"),
|
||||
)
|
||||
parts += [
|
||||
f"{count_text(number, noun, plural)} {verb}"
|
||||
for number, noun, plural, verb in landed_counts
|
||||
if number
|
||||
]
|
||||
return ", ".join(parts)
|
||||
return ", ".join([f"{counts['kept']} kept", *change_phrases(counts)])
|
||||
|
||||
|
||||
def _unwritten(refused: int, withheld: list[str], report: Report) -> list[str]:
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
"""The kinds of change an export writes into a platform's file, and how each is said."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import NamedTuple
|
||||
|
||||
from core.text import count_text
|
||||
|
||||
|
||||
class ChangeKind(NamedTuple):
|
||||
"""One kind of change, its count key in the report and its two wordings."""
|
||||
|
||||
key: str
|
||||
noun: str
|
||||
plural: str
|
||||
terse: str
|
||||
plain: str
|
||||
|
||||
|
||||
# In the order both sentences name them. `terse` is the run's summary,
|
||||
# `plain` the exports page.
|
||||
CHANGE_KINDS = (
|
||||
ChangeKind("added", "file", "", "added", "added"),
|
||||
ChangeKind("hash_updated", "hash", "", "updated to the emulator source", "updated"),
|
||||
ChangeKind("required_aligned", "required flag", "",
|
||||
"aligned with the code", "aligned with the code"),
|
||||
ChangeKind("hash_filled", "hash", "", "added to an existing entry", "added"),
|
||||
ChangeKind("size_updated", "size", "", "updated to the emulator source", "updated"),
|
||||
ChangeKind("size_removed", "size", "", "removed", "removed"),
|
||||
ChangeKind("hash_cleared", "hash", "", "removed", "removed"),
|
||||
ChangeKind("not_kept", "entry", "entries", "removed, the format cannot state them",
|
||||
"not written, the format cannot state them"),
|
||||
ChangeKind("md5_lists", "md5 list", "",
|
||||
"written, any listed value passes", "written, any listed value passes"),
|
||||
)
|
||||
|
||||
|
||||
def change_phrases(counts: dict, plain: bool = False) -> list[str]:
|
||||
"""Each change the counts hold, as "2 hashes removed", none for a zero."""
|
||||
return [
|
||||
f"{count_text(counts[kind.key], kind.noun, kind.plural)} "
|
||||
f"{kind.plain if plain else kind.terse}"
|
||||
for kind in CHANGE_KINDS
|
||||
if counts[kind.key]
|
||||
]
|
||||
@@ -12,6 +12,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from core.text import count_text
|
||||
from model.exportchanges import change_phrases
|
||||
from sitegen import markup
|
||||
|
||||
EXPORTS_DIR = "exports"
|
||||
@@ -95,24 +96,15 @@ def _lookup_only(block: list[str]) -> list[str]:
|
||||
def change_text(report: dict) -> str:
|
||||
"""What the updated file changes, from the report's numbers.
|
||||
|
||||
The command line prints its own terse summary. The page states each
|
||||
kind of change once, in plain terms, and leaves out what did not
|
||||
happen. RetroPie's unit is a package, so its own sentence is kept.
|
||||
The page names the changes the run's summary names, in plain terms,
|
||||
and leaves out what did not happen. RetroPie's unit is a package, so
|
||||
its own sentence is kept.
|
||||
"""
|
||||
counts = report.get("counts")
|
||||
if not counts:
|
||||
return report["summary"]
|
||||
parts = [f"{count_text(counts['kept'], 'entry', 'entries')} kept"]
|
||||
extra = [
|
||||
(counts["added"], "file", "files", "added"),
|
||||
(len(report.get("hashes_updated") or []), "hash", "hashes", "updated"),
|
||||
(report.get("required_aligned") or 0, "required flag", "required flags",
|
||||
"aligned with the code"),
|
||||
(len(report.get("hashes_filled") or []), "hash", "hashes", "added"),
|
||||
(len(report.get("sizes_updated") or []), "size", "sizes", "updated"),
|
||||
]
|
||||
parts += [f"{count_text(n, one, many)} {verb}" for n, one, many, verb in extra if n]
|
||||
return ", ".join(parts)
|
||||
kept = f"{count_text(counts['kept'], 'entry', 'entries')} kept"
|
||||
return ", ".join([kept, *change_phrases(counts, plain=True)])
|
||||
|
||||
|
||||
# Beyond this many entries a reason's list folds away.
|
||||
@@ -301,12 +293,6 @@ def generate_exports_page(reports: list[dict], names: dict[str, str]) -> str:
|
||||
"reasons above.",
|
||||
"",
|
||||
])
|
||||
if counts.get("not_kept"):
|
||||
lines.extend([
|
||||
f"{count_text(counts['not_kept'], 'entry', 'entries')} of the original "
|
||||
"cannot be written in this format and should be checked by hand.",
|
||||
"",
|
||||
])
|
||||
lines.extend(candidate_lines(report.get("removal_candidates") or []))
|
||||
lines.extend(doubled_lines(report.get("doubled") or []))
|
||||
if report.get("invalid"):
|
||||
|
||||
@@ -184,6 +184,7 @@ COMMANDS = {
|
||||
"bundled_only.py": ("packs/bundledonly.py",),
|
||||
"export_native.py": (
|
||||
"exporter/runner.py", "exporter/native.py", "exporter/originals.py", "exporter/landed.py",
|
||||
"model/exportchanges.py",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,20 @@ from pathlib import Path
|
||||
from exporter import native
|
||||
from exporter.landed import landed_changes
|
||||
from exporter.native import build_export, current_truth, write_report
|
||||
from model.exportchanges import CHANGE_KINDS
|
||||
from model.profiles import load_emulator_profiles
|
||||
from sitegen.exports import generate_exports_page, load_export_reports
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def _counts(**changed: int) -> dict:
|
||||
"""A report's counts with every kind of change at zero but *changed*."""
|
||||
counts = {"kept": 0, "not_added": 0} | {kind.key: 0 for kind in CHANGE_KINDS}
|
||||
counts.update(changed)
|
||||
return counts
|
||||
|
||||
|
||||
def _report(platform: str, files: list[str], **changes: object) -> dict:
|
||||
report = {
|
||||
"platform": platform,
|
||||
@@ -156,16 +164,42 @@ class ThePageAddressesMaintainersAsPeers(unittest.TestCase):
|
||||
|
||||
report = _report("batocera", ["batocera-systems"],
|
||||
hashes_updated=["a md5", "b md5"], required_aligned=3)
|
||||
report["counts"] = {"kept": 692, "added": 253, "not_added": 10, "not_kept": 0}
|
||||
report["counts"] = _counts(kept=692, added=253, not_added=10,
|
||||
hash_updated=2, required_aligned=3)
|
||||
self.assertEqual(
|
||||
change_text(report),
|
||||
"692 entries kept, 253 files added, 2 hashes updated, "
|
||||
"3 required flags aligned with the code",
|
||||
)
|
||||
|
||||
def test_the_page_names_every_change_the_run_names(self):
|
||||
"""The page rebuilt the sentence from its own five kinds and left out
|
||||
the sizes and hashes removed and the md5 lists the file carries."""
|
||||
from exporter.native import _landed_summary
|
||||
from sitegen.exports import change_text
|
||||
|
||||
counts = _counts(kept=519, **{kind.key: 1 for kind in CHANGE_KINDS})
|
||||
report = _report("retroarch", ["System.dat"], counts=counts)
|
||||
self.assertEqual(
|
||||
_landed_summary(counts),
|
||||
"519 kept, 1 file added, 1 hash updated to the emulator source, "
|
||||
"1 required flag aligned with the code, 1 hash added to an existing entry, "
|
||||
"1 size updated to the emulator source, 1 size removed, 1 hash removed, "
|
||||
"1 entry removed, the format cannot state them, "
|
||||
"1 md5 list written, any listed value passes",
|
||||
)
|
||||
self.assertEqual(
|
||||
change_text(report),
|
||||
"519 entries kept, 1 file added, 1 hash updated, "
|
||||
"1 required flag aligned with the code, 1 hash added, 1 size updated, "
|
||||
"1 size removed, 1 hash removed, "
|
||||
"1 entry not written, the format cannot state them, "
|
||||
"1 md5 list written, any listed value passes",
|
||||
)
|
||||
|
||||
def test_no_wording_that_judges_the_original(self):
|
||||
report = _report("batocera", ["batocera-systems"], hashes_updated=["a md5"])
|
||||
report["counts"] = {"kept": 1, "added": 0, "not_added": 4, "not_kept": 1}
|
||||
report["counts"] = _counts(kept=1, not_added=4, not_kept=1, hash_updated=1)
|
||||
page = generate_exports_page([report], {}).lower()
|
||||
for word in ("their file", "theirs", "corrected", "wrong", "drift", "left out"):
|
||||
self.assertNotIn(word, page)
|
||||
|
||||
Reference in new issue
Block a user