refactor: name export report changes as updates

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 14:59:47 +01:00
1 parent 0abe83da33
commit 3d420145c3
21 files changed
+499 -483

No files matched your search

+11 -11
View File
@@ -515,7 +515,7 @@ class LandedChanges:
@property
def applied(self) -> list[str]:
return self._labels("hash_corrected")
return self._labels("hash_updated")
@property
def filled(self) -> list[str]:
@@ -527,7 +527,7 @@ class LandedChanges:
@property
def resized(self) -> list[str]:
return [label.removesuffix(" size") for label in self._labels("size_corrected")]
return [label.removesuffix(" size") for label in self._labels("size_updated")]
@property
def unsized(self) -> list[str]:
@@ -535,7 +535,7 @@ class LandedChanges:
@property
def requirements(self) -> int:
return sum(r["kind"] == "requirement_corrected" for r in self.records)
return sum(r["kind"] == "required_aligned" for r in self.records)
@property
def lists(self) -> int:
@@ -624,14 +624,14 @@ def landed_changes(exporter: object, systems: dict) -> LandedChanges:
and exporter.required_value(entry) != bool(entry.platform["required"])
):
records.append(_change(
"requirement_corrected", entry, "required",
"required_aligned", entry, "required",
bool(entry.platform["required"]), exporter.required_value(entry),
))
for field_name in entry.corrections:
if field_name == "required" or not exporter.states(entry, field_name):
continue
records.append(_change(
"hash_corrected", entry, field_name,
"hash_updated", entry, field_name,
_platform_value(entry, field_name),
_written_value(exporter, entry, field_name),
))
@@ -648,7 +648,7 @@ def landed_changes(exporter: object, systems: dict) -> LandedChanges:
and exporter.states(entry, field_name)
):
records.append(_change(
"hash_corrected", entry, field_name,
"hash_updated", entry, field_name,
_platform_value(entry, field_name), listed,
))
records.extend(
@@ -666,7 +666,7 @@ def landed_changes(exporter: object, systems: dict) -> LandedChanges:
and exporter.states(entry, "size")
):
records.append(_change(
"size_corrected", entry, "size", _single_size(theirs), ours
"size_updated", entry, "size", _single_size(theirs), ours
))
elif (
theirs
@@ -690,7 +690,7 @@ def landed_changes(exporter: object, systems: dict) -> LandedChanges:
# A value the render rewrote though the model reads it as the
# platform's own (RomM's sha1 with a leading space).
records.extend(
_change("hash_corrected", entry, field_name, old, new)
_change("hash_updated", entry, field_name, old, new)
for entry, field_name, old, new in getattr(exporter, "normalized_values", [])
)
return changes
@@ -863,12 +863,12 @@ def export_platform(
"not_kept": lost,
},
"changes": changes.records,
"hashes_corrected": applied,
"hashes_updated": applied,
"hashes_filled": filled,
"sizes_corrected": resized,
"sizes_updated": resized,
"sizes_removed": unsized,
"hashes_cleared": cleared,
"requirements_corrected": requirements,
"required_aligned": requirements,
"withheld": list(withheld),
"found_by_content": report.labels,
"unattributed": report.unattributed,
+12 -12
View File
@@ -22,9 +22,9 @@ API_EXPORTS = "api/v1/exports"
# Report key, then how a line of it reads on the page.
CHANGE_KINDS = (
("hashes_corrected", "Hashes updated to the emulator source"),
("hashes_updated", "Hashes updated to the emulator source"),
("hashes_filled", "Hashes added where the original lists none"),
("sizes_corrected", "Sizes updated to the emulator source"),
("sizes_updated", "Sizes updated to the emulator source"),
("sizes_removed", "Sizes no longer stated"),
("hashes_cleared", "Hashes no longer listed"),
("withheld", "Changes not applied"),
@@ -33,9 +33,9 @@ CHANGE_KINDS = (
# Report key, then the kind each line of `changes` carries.
CHANGE_RECORDS = {
"hashes_corrected": "hash_corrected",
"hashes_updated": "hash_updated",
"hashes_filled": "hash_filled",
"sizes_corrected": "size_corrected",
"sizes_updated": "size_updated",
"sizes_removed": "size_removed",
"hashes_cleared": "hash_cleared",
}
@@ -52,11 +52,11 @@ def describe_change(change: dict) -> str:
"""One change in words, with the value before and after it."""
label = f"`{change['system']}/{change['name']}` {change['field']}"
kind, old, new = change["kind"], change["old"], change["new"]
if kind in ("hash_corrected", "size_corrected"):
if kind in ("hash_updated", "size_updated"):
return f"{label} {_value(old)} becomes {_value(new)}"
if kind == "hash_filled":
return f"{label} {_value(new)} added"
if kind == "requirement_corrected":
if kind == "required_aligned":
return f"`{change['system']}/{change['name']}` becomes {'required' if new else 'optional'}"
return f"{label} {_value(old)} no longer listed"
@@ -76,7 +76,7 @@ def requirement_lines(report: dict) -> list[str]:
"""Each required flag aligned with the code, and what it is now."""
items = [
describe_change(c) for c in report.get("changes") or []
if c["kind"] == "requirement_corrected"
if c["kind"] == "required_aligned"
]
if not items:
return []
@@ -108,11 +108,11 @@ def change_text(report: dict) -> str:
parts = [f"{_plural(counts['kept'], 'entry', 'entries')} kept"]
extra = [
(counts["added"], "file", "files", "added"),
(len(report.get("hashes_corrected") or []), "hash", "hashes", "updated"),
(report.get("requirements_corrected") or 0, "required flag", "required flags",
(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_corrected") or []), "size", "sizes", "updated"),
(len(report.get("sizes_updated") or []), "size", "sizes", "updated"),
]
parts += [f"{_plural(n, one, many)} {verb}" for n, one, many, verb in extra if n]
return ", ".join(parts)
@@ -216,7 +216,7 @@ def _display(platform: str, names: dict[str, str]) -> str:
return names.get(platform) or platform
def _corrected_link(report: dict) -> str:
def _updated_link(report: dict) -> str:
platform, files = report["platform"], report["files"]
if len(files) == 1:
path = f"{EXPORTS_DIR}/{platform}/{files[0]}"
@@ -286,7 +286,7 @@ def generate_exports_page(reports: list[dict], names: dict[str, str]) -> str:
platform = report["platform"]
lines.append(
f"| [{_display(platform, names)}](#{platform}) | "
f"{_original_link(report)} | {_corrected_link(report)} | "
f"{_original_link(report)} | {_updated_link(report)} | "
f"{change_text(report)} |"
)
lines.append("")