mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
fix: surface upstream entries a scraper drops
RomM skipped an unmapped IGDB slug and RetroDECK a second component's conflicting MD5 with a stderr warning only: the rescrape exited 0, the rewritten file showed no diff and check_freshness said OK. An unmapped slug now fails the RomM scrape. A deliberate drop goes in BaseScraper.dropped, scraper_cli prints it under DROPPED_PREFIX, and the freshness rescrape reports an otherwise unchanged platform UNKNOWN.
This commit is contained in:
1 parent
398782a5cd
commit
1b7d30967b
9 files changed
+171
-19
No files matched your search
@@ -148,6 +148,11 @@ def requirement_entry(req: BiosRequirement) -> dict:
|
||||
return entry
|
||||
|
||||
|
||||
# The stderr line a scraper CLI writes for each upstream entry the platform
|
||||
# file does not carry. The freshness rescrape reads them on exit 0, where the
|
||||
# diff of the rewritten file cannot show an entry that was never written.
|
||||
DROPPED_PREFIX = "dropped: "
|
||||
|
||||
SCRAPER_AGENT = "retrobios-scraper/1.0"
|
||||
GITHUB_API = "https://api.github.com"
|
||||
|
||||
@@ -403,6 +408,8 @@ class BaseScraper(ABC):
|
||||
|
||||
def __init__(self, url: str = "") -> None:
|
||||
self.url = url
|
||||
# Upstream entries left out of the platform file, each with its reason.
|
||||
self.dropped: list[str] = []
|
||||
self._raw_data: str | None = None
|
||||
self._json_data: dict | None = None
|
||||
|
||||
@@ -688,6 +695,8 @@ def scraper_cli(
|
||||
exit_on_scrape_error(RuntimeError(
|
||||
f"{scraper_class.__module__}: upstream returned no BIOS entry"
|
||||
))
|
||||
for reason in scraper.dropped:
|
||||
print(f"{DROPPED_PREFIX}{reason}", file=sys.stderr)
|
||||
|
||||
if args.dry_run:
|
||||
_print_dry_run(reqs)
|
||||
|
||||
@@ -363,9 +363,11 @@ def _entry_requirement(entry: dict, comp_key: str, default_system: object) -> Bi
|
||||
)
|
||||
|
||||
|
||||
def _warn_md5_conflict(
|
||||
def _md5_conflict(
|
||||
requirements: list[BiosRequirement], key: tuple[str, str], req: BiosRequirement
|
||||
) -> None:
|
||||
) -> str | None:
|
||||
"""Why *req* is left out: an earlier component declares the same file
|
||||
with another MD5. None for a plain repeat."""
|
||||
existing = next(
|
||||
(
|
||||
r
|
||||
@@ -376,11 +378,11 @@ def _warn_md5_conflict(
|
||||
)
|
||||
md5 = req.md5
|
||||
if existing and md5 and existing.md5 and md5 != existing.md5:
|
||||
print(
|
||||
f" WARNING: {req.name} ({req.system}): MD5 conflict "
|
||||
f"({existing.md5[:12]}... vs {md5[:12]}...)",
|
||||
file=sys.stderr,
|
||||
return (
|
||||
f"{req.name} ({req.system}): MD5 conflict "
|
||||
f"({existing.md5[:12]}... vs {md5[:12]}... in {req.native['component']})"
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
class Scraper(BaseScraper):
|
||||
@@ -493,7 +495,9 @@ class Scraper(BaseScraper):
|
||||
continue
|
||||
key = (req.system, req.name.lower())
|
||||
if key in seen:
|
||||
_warn_md5_conflict(requirements, key, req)
|
||||
conflict = _md5_conflict(requirements, key, req)
|
||||
if conflict:
|
||||
self.dropped.append(conflict)
|
||||
continue
|
||||
seen.add(key)
|
||||
requirements.append(req)
|
||||
|
||||
@@ -23,7 +23,6 @@ Slugs are IGDB-style platform identifiers.
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
@@ -174,6 +173,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
data = self._fetch_json()
|
||||
requirements: list[BiosRequirement] = []
|
||||
unmapped: set[str] = set()
|
||||
|
||||
for key, entry in data.items():
|
||||
if ":" not in key:
|
||||
@@ -182,7 +182,7 @@ class Scraper(BaseScraper):
|
||||
igdb_slug, filename = key.split(":", 1)
|
||||
system = SLUG_MAP.get(igdb_slug)
|
||||
if not system:
|
||||
print(f"Warning: unmapped IGDB slug '{igdb_slug}'", file=sys.stderr)
|
||||
unmapped.add(igdb_slug)
|
||||
continue
|
||||
|
||||
sha1 = (entry.get("sha1") or "").strip() or None
|
||||
@@ -211,6 +211,10 @@ class Scraper(BaseScraper):
|
||||
for slug in (igdb_slug, *mirrors)
|
||||
)
|
||||
|
||||
# Skipped, the slug's files left romm.yml with exit 0 and the
|
||||
# rescrape diff showed nothing for entries never written.
|
||||
if unmapped:
|
||||
raise ValueError(f"unmapped IGDB slug {', '.join(sorted(unmapped))}: add it to SLUG_MAP")
|
||||
return requirements
|
||||
|
||||
def validate_format(self, raw_data: str) -> bool:
|
||||
|
||||
Reference in new issue
Block a user