mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 09:23:26 -05:00
fix: scrape targets at the pinned platform release
This commit is contained in:
1 parent
cdab4e7808
commit
27d119cb7f
7 files changed
+70
-17
No files matched your search
@@ -7,6 +7,7 @@ from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import pkgutil
|
||||
import re
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
@@ -22,6 +23,35 @@ class BaseTargetScraper(ABC):
|
||||
"""Fetch targets and their core lists. Returns dict matching target YAML format."""
|
||||
...
|
||||
|
||||
@staticmethod
|
||||
def pinned_revision(platform: str, platforms_dir: str | None = None) -> str:
|
||||
"""The upstream revision platforms/<platform>.yml was scraped at.
|
||||
|
||||
A target list describes the same release as the platform's BIOS
|
||||
list: read on its own "latest stable tag", a Recalbox 10.2 board list
|
||||
filtered 10.1.1 systems. Moving to a new release is a rescrape of the
|
||||
platform first.
|
||||
"""
|
||||
import yaml
|
||||
|
||||
directory = Path(platforms_dir) if platforms_dir else (
|
||||
Path(__file__).resolve().parents[3] / "platforms"
|
||||
)
|
||||
with open(directory / f"{platform}.yml", encoding="utf-8") as handle:
|
||||
source = str((yaml.safe_load(handle) or {}).get("source", ""))
|
||||
for pattern in (
|
||||
r"^https://raw\.githubusercontent\.com/[^/]+/[^/]+/([^/]+)/",
|
||||
r"^https://github\.com/[^/]+/[^/]+/(?:blob|tree)/([^/]+)/",
|
||||
r"^https://gitlab\.com/.+?/-/(?:raw|blob|tree)/([^/]+)/",
|
||||
):
|
||||
match = re.match(pattern, source)
|
||||
if match:
|
||||
return match.group(1)
|
||||
raise RuntimeError(
|
||||
f"platforms/{platform}.yml names no pinned revision in its source "
|
||||
f"({source!r}): rescrape the platform first"
|
||||
)
|
||||
|
||||
def write_output(self, data: dict, output_path: str) -> None:
|
||||
"""Write target data to YAML file."""
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user