mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: refuse a platform scrape that lists no file
scraper_cli wrote a platform YAML with no system when the parse came back empty, and exited 0. It now exits 1 before writing, unless the scraper declares lists_files = False (RetroPie, whose files are inherited); RetroPie in turn raises when its archive declares no package.
This commit is contained in:
1 parent
981468874c
commit
6318eaa28b
3 files changed
+82
No files matched your search
@@ -164,6 +164,11 @@ def fetch_bytes(
|
||||
class BaseScraper(ABC):
|
||||
"""Abstract base class for platform BIOS requirement scrapers."""
|
||||
|
||||
# False for a platform whose file list is inherited and whose scraper
|
||||
# reads only its core list (RetroPie). Otherwise an empty read is an
|
||||
# upstream that changed shape, never a platform with no file.
|
||||
lists_files: bool = True
|
||||
|
||||
def __init__(self, url: str = "") -> None:
|
||||
self.url = url
|
||||
self._raw_data: str | None = None
|
||||
@@ -366,6 +371,12 @@ def scraper_cli(
|
||||
reqs = scraper.fetch_requirements()
|
||||
except (OSError, ValueError, RuntimeError) as e:
|
||||
_exit_on_scrape_error(e)
|
||||
if scraper.lists_files and not reqs:
|
||||
# Written, an empty read became a platform with no system that
|
||||
# verify and the pack count 0/0 and call consistent.
|
||||
_exit_on_scrape_error(RuntimeError(
|
||||
f"{scraper_class.__module__}: upstream returned no BIOS entry"
|
||||
))
|
||||
|
||||
if args.dry_run:
|
||||
by_system: dict[str, list] = {}
|
||||
@@ -425,6 +436,12 @@ def scraper_cli(
|
||||
if req.zipped_file:
|
||||
entry["zipped_file"] = req.zipped_file
|
||||
config["systems"][sys_id]["files"].append(entry)
|
||||
if scraper.lists_files and not any(
|
||||
(system or {}).get("files") for system in (config.get("systems") or {}).values()
|
||||
):
|
||||
_exit_on_scrape_error(RuntimeError(
|
||||
f"{scraper_class.__module__}: the generated platform lists no file"
|
||||
))
|
||||
# Merge into existing YAML: preserve fields the scraper doesn't generate
|
||||
# (data_directories, case_insensitive_fs, manually added metadata).
|
||||
# The scraper replaces systems + files, everything else is preserved.
|
||||
|
||||
@@ -59,6 +59,8 @@ _PACKAGE_DIRS = _SCRIPT_SECTIONS
|
||||
class Scraper(BaseScraper):
|
||||
"""Scraper for the RetroPie package list."""
|
||||
|
||||
lists_files = False
|
||||
|
||||
def __init__(self, url: str | None = None) -> None:
|
||||
# The package list is read from master: the commit read is recorded.
|
||||
if url is None:
|
||||
@@ -122,6 +124,8 @@ class Scraper(BaseScraper):
|
||||
else:
|
||||
found.add(match.group(1))
|
||||
|
||||
if not found:
|
||||
raise ValueError(f"{self.url}: no rp_module_id under {SCRIPTMODULES}/")
|
||||
self._modules = sorted(found)
|
||||
return self._modules
|
||||
|
||||
|
||||
Reference in new issue
Block a user