mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 03:18:52 -06:00
refactor: log truth hash conflicts, not print
This commit is contained in:
1 parent
3e55385410
commit
3b16ee2633
5 files changed
+26
-31
No files matched your search
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import sys
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
|
||||
@@ -14,6 +13,7 @@ from exporter.originals import SOURCES_INDEX, SourcesIndexUnreadable, load_sourc
|
||||
from model.platforms import inheritance_chain
|
||||
from model.registry import list_registered_platforms
|
||||
from resolve.reconcile import build_native_model
|
||||
from resolve.truth import log as truth_log
|
||||
from freshness.findings import ERROR, OK, STALE, Finding
|
||||
|
||||
|
||||
@@ -92,25 +92,20 @@ def _transcribed_at(platforms_dir: Path, platform: str) -> float:
|
||||
)
|
||||
|
||||
|
||||
# How the truth model settles two cores' hashes: generate_truth reports it,
|
||||
# and it says nothing about whether a cached original is current.
|
||||
_MODEL_NOTES = ("WARNING: hash conflict",)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _without_model_notes() -> Iterator[None]:
|
||||
"""Keep the model build's own notes out of the freshness report.
|
||||
"""Keep the truth model's own notes out of the freshness report.
|
||||
|
||||
Anything else written to stderr passes through.
|
||||
generate_truth reports how two cores' hashes were settled, and that says
|
||||
nothing about whether a cached original is current. Anything else
|
||||
written to stderr passes through.
|
||||
"""
|
||||
sink = io.StringIO()
|
||||
previous = truth_log.disabled
|
||||
truth_log.disabled = True
|
||||
try:
|
||||
with contextlib.redirect_stderr(sink):
|
||||
yield
|
||||
yield
|
||||
finally:
|
||||
for line in sink.getvalue().splitlines(keepends=True):
|
||||
if not line.startswith(_MODEL_NOTES):
|
||||
sys.stderr.write(line)
|
||||
truth_log.disabled = previous
|
||||
|
||||
|
||||
def check_native(
|
||||
|
||||
@@ -7,8 +7,8 @@ and diffs truth against scraped platform data to find divergences.
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
from model.declarations import OUTER_ROOTS
|
||||
@@ -30,6 +30,10 @@ from resolve.validation import (
|
||||
from core.paths import REPO_ROOT
|
||||
|
||||
|
||||
# Notes on how the model settled two cores: a caller that has no use for
|
||||
# them (check_freshness) silences this logger, never the text it writes.
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
_CONFLICTS_SHOWN: set[tuple[str, ...]] = set()
|
||||
|
||||
|
||||
@@ -336,11 +340,10 @@ def _merge_hashes(
|
||||
# Both cores and which value stays: naming only the second
|
||||
# core sent the reader through ten profiles for the first.
|
||||
first = existing.get("_hash_by", {}).get(h, "an earlier core")
|
||||
print(
|
||||
f"WARNING: hash conflict for {file_entry['name']}: "
|
||||
f"{h} {ours} ({first}) kept, {theirs} ({emu_name}) "
|
||||
log.warning(
|
||||
"WARNING: hash conflict for %s: %s %s (%s) kept, %s (%s) "
|
||||
"left out of the model",
|
||||
file=sys.stderr,
|
||||
file_entry["name"], h, ours, first, theirs, emu_name,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user