mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 12:58:51 -06:00
refactor: read RetroPie scripts from one tarball
script_members in retropie_scraper yields every shell script of a RetroPie-Setup tarball. The platform scraper, the exporter and the target scraper read the scripts through it. The target scraper fetched one contents listing per section and about 200 raw files; it now reads the tarball of the pinned revision in one request. On the cached tarball the three produce the same module ids, scripts, BIOS-bearing scripts and targets as before. The targets file keeps its source URL.
This commit is contained in:
1 parent
f7c08a6ca3
commit
0332f6149a
4 files changed
+114
-97
No files matched your search
@@ -13,15 +13,14 @@ to document from scratch is reported, not drafted.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import re
|
||||
import sys
|
||||
import tarfile
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from model.profiles import load_emulator_profiles
|
||||
from scraper.retropie_scraper import script_members
|
||||
|
||||
from .base_exporter import BaseExporter
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, search_order
|
||||
@@ -92,22 +91,11 @@ class Exporter(BaseExporter[str]):
|
||||
@staticmethod
|
||||
def unpack(raw: bytes) -> dict[str, str]:
|
||||
"""Keep the scriptmodules that say anything about BIOS files."""
|
||||
found: dict[str, str] = {}
|
||||
with tarfile.open(fileobj=io.BytesIO(raw), mode="r:gz") as archive:
|
||||
for member in archive:
|
||||
if not member.isfile() or not member.name.endswith(".sh"):
|
||||
continue
|
||||
relative = member.name.split("/", 1)[-1]
|
||||
if not relative.startswith("scriptmodules/"):
|
||||
continue
|
||||
handle = archive.extractfile(member)
|
||||
if handle is None:
|
||||
continue
|
||||
text = handle.read().decode("utf-8", errors="replace")
|
||||
# xm7, np2pi, quasi88 and five more write "bios".
|
||||
if "bios" in text.lower():
|
||||
found[relative] = text
|
||||
return found
|
||||
# xm7, np2pi, quasi88 and five more write "bios".
|
||||
return {
|
||||
relative: text for relative, text in script_members(raw)
|
||||
if relative.startswith("scriptmodules/") and "bios" in text.lower()
|
||||
}
|
||||
|
||||
def _core_index(self) -> dict[str, dict[str, str]]:
|
||||
"""Module id (without its lr- prefix) to the profile it stands for,
|
||||
|
||||
Reference in new issue
Block a user