refactor: one loader for the rom-folder sources

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:40 +01:00
1 parent 17c64914ef
commit 1631ad0f4d
7 files changed
+32 -35

No files matched your search

-9
View File
@@ -26,7 +26,6 @@ if (_SCRIPTS_DIR := str(Path(__file__).resolve().parents[2])) not in sys.path:
sys.path.insert(0, _SCRIPTS_DIR)
from core import upstream
from model.sources import source_yaml_file
from ..base_scraper import PlatformDumper
@@ -160,14 +159,6 @@ def load_formats() -> dict[str, Parser]:
return FORMATS
def load_sources(directory: Path) -> dict[str, dict]:
"""Each setup's declared sources and facts, keyed by its file name."""
out: dict[str, dict] = {}
for path in sorted(Path(directory).glob("*.yml")):
out[path.stem] = source_yaml_file(path) or {}
return out
def _clean_row(row: dict) -> dict:
unknown = set(row) - set(ROW_KEYS)
if unknown:
+5 -6
View File
@@ -11,11 +11,10 @@ import argparse
import sys
from pathlib import Path
from . import Fetcher, SourceError, dump_setup, load_sources, scrape_setup
from . import Fetcher, SourceError, dump_setup, scrape_setup
from core.upstream import UpstreamError
from core.artifacts import write_if_changed
DEFAULT_DIR = Path("platforms") / "romfolders"
from model.romfolders import ROMFOLDERS_DIR, SOURCES_DIR, load_sources
def main() -> int:
@@ -24,10 +23,10 @@ def main() -> int:
which.add_argument("--setup", action="append", help="setup id (repeatable)")
which.add_argument("--all", action="store_true", help="every setup of the sources file")
which.add_argument("--list", action="store_true", help="list the setups and their format")
parser.add_argument("--sources", type=Path, default=DEFAULT_DIR / "_sources",
parser.add_argument("--sources", type=Path, default=SOURCES_DIR,
help="the setups, their repositories and pinned revisions")
parser.add_argument("--output-dir", type=Path, default=DEFAULT_DIR,
help=f"where <setup>.yml is written (default {DEFAULT_DIR})")
parser.add_argument("--output-dir", type=Path, default=ROMFOLDERS_DIR,
help=f"where <setup>.yml is written (default {ROMFOLDERS_DIR})")
parser.add_argument("--offline", action="store_true", help="read the revision cache only")
parser.add_argument("--dry-run", action="store_true", help="print counts, write nothing")
args = parser.parse_args()