mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 10:37:54 -06:00
refactor: public names for cross-module reads
This commit is contained in:
1 parent
f371790dc6
commit
3853ca2f1c
254 files changed
+2955
-2969
No files matched your search
@@ -11,7 +11,7 @@ import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from model.safeparse import yaml_load
|
||||
from model.registry import _load_versions
|
||||
from model.registry import load_versions
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -76,7 +76,7 @@ def check(registry_path: str = DEFAULT_REGISTRY) -> dict:
|
||||
return {"error": str(exc), "entries": []}
|
||||
|
||||
tracked = load_tracked_entries(registry_path)
|
||||
versions = _load_versions()
|
||||
versions = load_versions()
|
||||
|
||||
buildbot_set = set(index_zips)
|
||||
tracked_set = set(tracked.keys())
|
||||
|
||||
@@ -188,14 +188,14 @@ _RE_ARRAY = re.compile(
|
||||
|
||||
# checkBIOS.sh declares its checks as `checkPS1BIOS(){`, with no `function`
|
||||
# keyword and no settled casing for BIOS.
|
||||
_RE_FUNC = re.compile(
|
||||
RE_FUNC = re.compile(
|
||||
r"^[ \t]*(?:function\s+)?(check\w*(?:BIOS|Bios))\s*\(\)\s*\{",
|
||||
re.MULTILINE,
|
||||
)
|
||||
|
||||
# The hash list is named differently in each check (PSBios, hashes, ...), so
|
||||
# it is found by shape rather than by name.
|
||||
_RE_LOCAL_HASHES = re.compile(
|
||||
RE_LOCAL_HASHES = re.compile(
|
||||
r"(?:local\s+)?\w+=\(\s*((?:[0-9a-fA-F]{32}\s*)+)\)",
|
||||
re.MULTILINE,
|
||||
)
|
||||
@@ -276,16 +276,16 @@ class Scraper(BaseScraper):
|
||||
def _parse_function_hashes(self, script: str) -> dict[str, list[str]]:
|
||||
"""Extract local hash arrays from named check functions."""
|
||||
result: dict[str, list[str]] = {}
|
||||
for func_match in _RE_FUNC.finditer(script):
|
||||
for func_match in RE_FUNC.finditer(script):
|
||||
func_name = func_match.group(1)
|
||||
if func_name not in FUNCTION_HASH_MAP:
|
||||
continue
|
||||
system = FUNCTION_HASH_MAP[func_name]
|
||||
func_start = func_match.start()
|
||||
next_func = _RE_FUNC.search(script, func_match.end())
|
||||
next_func = RE_FUNC.search(script, func_match.end())
|
||||
func_end = next_func.start() if next_func else len(script)
|
||||
func_body = script[func_start:func_end]
|
||||
local_match = _RE_LOCAL_HASHES.search(func_body)
|
||||
local_match = RE_LOCAL_HASHES.search(func_body)
|
||||
if local_match:
|
||||
hashes_raw = local_match.group(1)
|
||||
hashes = [h.strip() for h in hashes_raw.split() if h.strip()]
|
||||
|
||||
@@ -164,8 +164,8 @@ SERIAL_NOTE = (
|
||||
|
||||
_PAREN = re.compile(r"\(([^)]+)\)")
|
||||
_NOINTRO_MEMBER = re.compile(r"^(?P<name>.+) \((?P<version>\d{8}-\d{6})\)\.dat$")
|
||||
_DISPOSITION = re.compile(r'filename="(?P<file>[^"]+)"')
|
||||
_REDUMP_FILE = re.compile(
|
||||
DISPOSITION = re.compile(r'filename="(?P<file>[^"]+)"')
|
||||
REDUMP_FILE = re.compile(
|
||||
r"^(?P<name>.+) - Datfile \((?P<count>\d+)\) \((?P<date>\d{4}-\d{2}-\d{2}) (?P<time>[\d-]+)\)\.(?:zip|dat)$"
|
||||
)
|
||||
|
||||
@@ -343,7 +343,7 @@ def fetch_redump(code: str, cache_dir: Path, offline: bool, refresh: bool) -> tu
|
||||
raise NotCachedError(f"{pack} is not cached")
|
||||
url = REDUMP_DATFILE_URL.format(code=code)
|
||||
kept = _download(url, pack)
|
||||
match = _DISPOSITION.search(kept["content_disposition"])
|
||||
match = DISPOSITION.search(kept["content_disposition"])
|
||||
if not match:
|
||||
raise RuntimeError(f"{url} answered without a datfile name")
|
||||
meta = {"file": match["file"], "url": url, "fetched": _today()}
|
||||
@@ -400,7 +400,7 @@ def import_redump(pack: Path, meta: dict) -> list[dict]:
|
||||
if dat_name not in by_name:
|
||||
continue
|
||||
file = meta.get("file", member)
|
||||
stamp = _REDUMP_FILE.match(file)
|
||||
stamp = REDUMP_FILE.match(file)
|
||||
origin = {
|
||||
"fetched_from": meta.get("url", ""),
|
||||
"fetched": meta.get("fetched", ""),
|
||||
|
||||
@@ -16,7 +16,7 @@ from pathlib import Path
|
||||
# Macros that declare a machine entry. GAMEL is GAME plus a layout and is
|
||||
# the only suffixed form MAME declares (src/emu/gamedrv.h): a BIOS root that
|
||||
# ships a layout, such as gq863 or aristmk5, is written with it.
|
||||
_MACHINE_MACROS = re.compile(
|
||||
MACHINE_MACROS = re.compile(
|
||||
r"\b(GAMEL|GAME|SYST|COMP|CONS)\s*\(",
|
||||
re.MULTILINE,
|
||||
)
|
||||
@@ -127,7 +127,7 @@ def find_bios_root_sets(source: str, filename: str) -> dict[str, dict]:
|
||||
"""
|
||||
results: dict[str, dict] = {}
|
||||
|
||||
for match in _MACHINE_MACROS.finditer(source):
|
||||
for match in MACHINE_MACROS.finditer(source):
|
||||
start = match.end() - 1 # position of opening paren
|
||||
block_end = _find_closing_paren(source, start)
|
||||
if block_end == -1:
|
||||
|
||||
@@ -120,11 +120,11 @@ class Fetcher:
|
||||
paths: list[str] = []
|
||||
for page in range(1, upstream.MAX_TREE_PAGES + 1):
|
||||
url = (
|
||||
f"{repo.api_base}/projects/{upstream._project(repo)}/repository/tree"
|
||||
f"{repo.api_base}/projects/{upstream.project_path(repo)}/repository/tree"
|
||||
f"?ref={sha}&path={directory}&recursive={'true' if recursive else 'false'}"
|
||||
f"&per_page={upstream.TREE_PAGE_SIZE}&page={page}"
|
||||
)
|
||||
payload = upstream._api(url, self.cache_dir, self.offline)
|
||||
payload = upstream.cached_api(url, self.cache_dir, self.offline)
|
||||
if not isinstance(payload, list):
|
||||
raise SourceError(f"{repo.slug}@{sha[:8]}: {directory} could not be listed")
|
||||
paths.extend(
|
||||
|
||||
Reference in new issue
Block a user