mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
refactor: drop dead scraper import fallbacks
This commit is contained in:
1 parent
3e732fd57e
commit
34eee3f087
27 files changed
+233
-424
No files matched your search
@@ -21,28 +21,16 @@ import re
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from .configgen_launchers import Launcher, Source
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
Script,
|
||||
config_placement,
|
||||
describe_keys,
|
||||
evidence_fields,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
except ImportError:
|
||||
from configgen_launchers import Launcher, Source # type: ignore[no-redef]
|
||||
from shell_launchers import ( # type: ignore[no-redef]
|
||||
LauncherPatternMissing,
|
||||
Script,
|
||||
config_placement,
|
||||
describe_keys,
|
||||
evidence_fields,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
from .configgen_launchers import Launcher, Source
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
Script,
|
||||
config_placement,
|
||||
describe_keys,
|
||||
evidence_fields,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
|
||||
BIOS = "/storage/roms/bios"
|
||||
RUNEMU = "packages/amberelec/sources/scripts/runemu.py"
|
||||
|
||||
@@ -423,7 +423,7 @@ def duckstation_legacy(cg: Configgen) -> list[Launcher]:
|
||||
|
||||
list_nodes = {name: src.assignment(name, generate) for name, _v, _f, _d in loops}
|
||||
tracked = {*list_nodes, *(v for _l, v, _f, _d in loops), flag}
|
||||
first_list = min(list_nodes.values(), key=lambda node: node.lineno)
|
||||
first_list = min(list_nodes.values(), key=lambda node: node.lineno).node
|
||||
body, index = _locate(generate, lambda stmt: stmt is first_list) # type: ignore[misc]
|
||||
sections = {section for section, _key in writes.values()}
|
||||
first, last = _run(body, index, lambda stmt: _mentions(stmt, sections, tracked))
|
||||
@@ -1127,10 +1127,7 @@ SEARCH_PATH_GENERATORS = ("mame/mameGenerator.py",)
|
||||
def search_paths(cg: Configgen) -> list[Launcher]:
|
||||
"""Every /userdata/bios path a generator's command line names, read as
|
||||
KNULLI's generic reader reads its fork of the same generator."""
|
||||
try:
|
||||
from .knulli_launchers import GenericSites, bios_sites
|
||||
except ImportError:
|
||||
from knulli_launchers import GenericSites, bios_sites # type: ignore[no-redef]
|
||||
from .knulli_launchers import GenericSites, bios_sites
|
||||
# A boot disk image the command line names (the Macintosh's
|
||||
# /userdata/bios/<boot_disk>.img) is a file, no search path.
|
||||
return [
|
||||
|
||||
@@ -20,22 +20,13 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
requirement_entry,
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
scraper_cli,
|
||||
)
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
requirement_entry,
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
scraper_cli,
|
||||
)
|
||||
from .base_scraper import (
|
||||
requirement_entry,
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
scraper_cli,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "bizhawk"
|
||||
|
||||
|
||||
@@ -10,13 +10,30 @@ from __future__ import annotations
|
||||
import ast
|
||||
from collections.abc import Callable, Iterator
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, NoReturn
|
||||
from typing import Any, NoReturn, Protocol
|
||||
|
||||
|
||||
class LauncherShapeError(ValueError):
|
||||
"""A generator no longer has the shape its extractor reads."""
|
||||
|
||||
|
||||
class Located(Protocol):
|
||||
"""A node that carries source lines: a statement, an expression, an argument."""
|
||||
|
||||
@property
|
||||
def lineno(self) -> int: ...
|
||||
|
||||
@property
|
||||
def end_lineno(self) -> int | None: ...
|
||||
|
||||
|
||||
def end_line(node: Located) -> int:
|
||||
"""The last line of a parsed node, which ast.parse always sets."""
|
||||
if node.end_lineno is None:
|
||||
raise LauncherShapeError(f"node at line {node.lineno} has no end line")
|
||||
return node.end_lineno
|
||||
|
||||
|
||||
@dataclass
|
||||
class Launcher:
|
||||
"""One thing a launcher looks for or hands over, as its code says it."""
|
||||
@@ -60,6 +77,22 @@ class Launcher:
|
||||
return {key: getattr(self, key) for key in order if getattr(self, key) is not None}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Assignment:
|
||||
"""A single-name assignment statement and the value it binds."""
|
||||
|
||||
node: ast.Assign | ast.AnnAssign
|
||||
value: ast.expr
|
||||
|
||||
@property
|
||||
def lineno(self) -> int:
|
||||
return self.node.lineno
|
||||
|
||||
@property
|
||||
def end_lineno(self) -> int | None:
|
||||
return self.node.end_lineno
|
||||
|
||||
|
||||
class Source:
|
||||
"""One configgen file, parsed, with the lines its nodes span."""
|
||||
|
||||
@@ -83,27 +116,28 @@ class Source:
|
||||
self.fail(f"expected one function {name}, found {len(found)}")
|
||||
return found[0]
|
||||
|
||||
def assignment(self, name: str, scope: ast.AST | None = None) -> ast.Assign | ast.AnnAssign:
|
||||
def assignment(self, name: str, scope: ast.AST | None = None) -> Assignment:
|
||||
found = [
|
||||
node for node in ast.walk(scope or self.tree)
|
||||
if _assigned_name(node) == name
|
||||
Assignment(node, assigned[1]) for node in ast.walk(scope or self.tree)
|
||||
if isinstance(node, (ast.Assign, ast.AnnAssign))
|
||||
and (assigned := assigned_value(node)) is not None and assigned[0] == name
|
||||
]
|
||||
if len(found) != 1:
|
||||
self.fail(f"expected one assignment to {name}, found {len(found)}")
|
||||
return found[0]
|
||||
|
||||
def literal(self, node: ast.AST | None, what: str) -> Any:
|
||||
def literal(self, node: ast.AST, what: str) -> Any:
|
||||
try:
|
||||
return ast.literal_eval(node) # type: ignore[arg-type]
|
||||
return ast.literal_eval(node)
|
||||
except (ValueError, TypeError, SyntaxError) as e:
|
||||
self.fail(f"{what} is not a literal: {e}")
|
||||
|
||||
def span(self, node: ast.AST) -> tuple[int, int]:
|
||||
def span(self, node: Located) -> tuple[int, int]:
|
||||
"""Lines of a node, with the comment lines written right above it."""
|
||||
start = node.lineno # type: ignore[attr-defined]
|
||||
start = node.lineno
|
||||
while start > 1 and self.lines[start - 2].strip().startswith("#"):
|
||||
start -= 1
|
||||
return start, node.end_lineno # type: ignore[attr-defined]
|
||||
return start, end_line(node)
|
||||
|
||||
def ref(self, spans: list[tuple[int, int]]) -> str:
|
||||
"""`path:a-b, c-d`, ranges joined across blank and comment lines."""
|
||||
@@ -123,14 +157,20 @@ class Source:
|
||||
)
|
||||
|
||||
|
||||
def _assigned_name(node: ast.AST) -> str | None:
|
||||
def assigned_value(node: ast.AST) -> tuple[str, ast.expr] | None:
|
||||
"""The name a single-name assignment binds, and the value it binds."""
|
||||
if isinstance(node, ast.Assign) and len(node.targets) == 1:
|
||||
target = node.targets[0]
|
||||
target, value = node.targets[0], node.value
|
||||
elif isinstance(node, ast.AnnAssign) and node.value is not None:
|
||||
target = node.target
|
||||
target, value = node.target, node.value
|
||||
else:
|
||||
return None
|
||||
return target.id if isinstance(target, ast.Name) else None
|
||||
return (target.id, value) if isinstance(target, ast.Name) else None
|
||||
|
||||
|
||||
def _assigned_name(node: ast.AST) -> str | None:
|
||||
assigned = assigned_value(node)
|
||||
return assigned[0] if assigned is not None else None
|
||||
|
||||
|
||||
def _statement_lists(node: ast.AST) -> Iterator[list[ast.stmt]]:
|
||||
@@ -202,11 +242,11 @@ def _enclosing_test(scope: ast.AST, node: ast.AST) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _innermost_function(src: Source, node: ast.AST) -> ast.FunctionDef:
|
||||
def _innermost_function(src: Source, node: ast.stmt | ast.expr) -> ast.FunctionDef:
|
||||
holders = [
|
||||
f for f in ast.walk(src.tree)
|
||||
if isinstance(f, ast.FunctionDef) and any(child is node for child in ast.walk(f))
|
||||
]
|
||||
if not holders:
|
||||
src.fail(f"line {node.lineno} is outside any function") # type: ignore[attr-defined]
|
||||
src.fail(f"line {node.lineno} is outside any function")
|
||||
return max(holders, key=lambda f: f.lineno)
|
||||
@@ -13,30 +13,26 @@ Complements libretro_scraper (System.dat) with:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
)
|
||||
except ImportError:
|
||||
if not __package__:
|
||||
# Allow running directly: python scripts/scraper/coreinfo_scraper.py
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
||||
from scraper.base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
)
|
||||
importlib.import_module("scraper")
|
||||
__package__ = "scraper"
|
||||
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "libretro_coreinfo"
|
||||
|
||||
|
||||
@@ -14,28 +14,16 @@ import posixpath
|
||||
import re
|
||||
from collections.abc import Callable
|
||||
|
||||
try:
|
||||
from .configgen_launchers import Launcher
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
RepoTree,
|
||||
Script,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
words,
|
||||
)
|
||||
except ImportError:
|
||||
from configgen_launchers import Launcher
|
||||
from shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
RepoTree,
|
||||
Script,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
words,
|
||||
)
|
||||
from .configgen_launchers import Launcher
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
RepoTree,
|
||||
Script,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
words,
|
||||
)
|
||||
|
||||
EMUSCRIPTS = "functions/EmuScripts"
|
||||
CONFIGS = "configs"
|
||||
|
||||
@@ -17,28 +17,16 @@ import re
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from .emudeck_launchers import emulator_of_script, extract_launchers
|
||||
from .shell_launchers import RepoTree
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from emudeck_launchers import emulator_of_script, extract_launchers
|
||||
from shell_launchers import RepoTree
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from .emudeck_launchers import emulator_of_script, extract_launchers
|
||||
from .shell_launchers import RepoTree
|
||||
|
||||
PLATFORM_NAME = "emudeck"
|
||||
|
||||
|
||||
@@ -28,62 +28,31 @@ from typing import Any
|
||||
|
||||
import yaml
|
||||
|
||||
try:
|
||||
from .batocera_launchers import (
|
||||
PATH_PATCHES,
|
||||
Configgen,
|
||||
config_directories,
|
||||
_path_value,
|
||||
_render,
|
||||
_system_branches,
|
||||
duckstation,
|
||||
duckstation_legacy,
|
||||
environment_directories,
|
||||
hatari,
|
||||
melonds,
|
||||
mupen64plus,
|
||||
patched_paths,
|
||||
x16emu,
|
||||
working_directories,
|
||||
xemu,
|
||||
)
|
||||
from .configgen_launchers import (
|
||||
Launcher,
|
||||
LauncherShapeError,
|
||||
Source,
|
||||
_assigned_name,
|
||||
)
|
||||
from .shell_launchers import LauncherPatternMissing, Script, source_ref
|
||||
except ImportError:
|
||||
from batocera_launchers import ( # type: ignore[no-redef]
|
||||
PATH_PATCHES,
|
||||
Configgen,
|
||||
config_directories,
|
||||
_path_value,
|
||||
_render,
|
||||
_system_branches,
|
||||
duckstation,
|
||||
duckstation_legacy,
|
||||
environment_directories,
|
||||
hatari,
|
||||
melonds,
|
||||
mupen64plus,
|
||||
patched_paths,
|
||||
x16emu,
|
||||
working_directories,
|
||||
xemu,
|
||||
)
|
||||
from configgen_launchers import ( # type: ignore[no-redef]
|
||||
Launcher,
|
||||
LauncherShapeError,
|
||||
Source,
|
||||
_assigned_name,
|
||||
)
|
||||
from shell_launchers import ( # type: ignore[no-redef]
|
||||
LauncherPatternMissing,
|
||||
Script,
|
||||
source_ref,
|
||||
)
|
||||
from .batocera_launchers import (
|
||||
PATH_PATCHES,
|
||||
Configgen,
|
||||
config_directories,
|
||||
_path_value,
|
||||
_render,
|
||||
_system_branches,
|
||||
duckstation,
|
||||
duckstation_legacy,
|
||||
environment_directories,
|
||||
hatari,
|
||||
melonds,
|
||||
mupen64plus,
|
||||
patched_paths,
|
||||
x16emu,
|
||||
working_directories,
|
||||
xemu,
|
||||
)
|
||||
from .configgen_launchers import (
|
||||
Launcher,
|
||||
LauncherShapeError,
|
||||
Source,
|
||||
_assigned_name,
|
||||
)
|
||||
from .shell_launchers import LauncherPatternMissing, Script, source_ref
|
||||
|
||||
CONFIGGEN = "package/system/knulli-configgen/configgen/configgen"
|
||||
GENERATORS = f"{CONFIGGEN}/generators"
|
||||
|
||||
@@ -29,22 +29,13 @@ import urllib.parse
|
||||
from collections.abc import Callable, Mapping
|
||||
from dataclasses import dataclass
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
github_headers,
|
||||
)
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
github_headers,
|
||||
)
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
github_headers,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "minui"
|
||||
|
||||
@@ -336,10 +327,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape the MinUI pak list")
|
||||
|
||||
|
||||
@@ -28,22 +28,13 @@ import urllib.request
|
||||
import zipfile
|
||||
from datetime import datetime, timezone
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
_read_limited,
|
||||
fetch_branch_head,
|
||||
requirement_entry,
|
||||
)
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
_read_limited,
|
||||
fetch_branch_head,
|
||||
requirement_entry,
|
||||
)
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
_read_limited,
|
||||
fetch_branch_head,
|
||||
requirement_entry,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "misterfpga"
|
||||
|
||||
@@ -238,10 +229,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
def main() -> None:
|
||||
"""Entry point."""
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape MiSTer FPGA BIOS requirements")
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
try:
|
||||
from . import minui_scraper
|
||||
except ImportError:
|
||||
import minui_scraper
|
||||
from . import minui_scraper
|
||||
|
||||
PLATFORM_NAME = "myminui"
|
||||
|
||||
@@ -18,10 +15,7 @@ class Scraper(minui_scraper.Scraper):
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape the MyMinUI pak list")
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
try:
|
||||
from . import minui_scraper
|
||||
except ImportError:
|
||||
import minui_scraper
|
||||
from . import minui_scraper
|
||||
|
||||
PLATFORM_NAME = "nextui"
|
||||
|
||||
@@ -18,10 +15,7 @@ class Scraper(minui_scraper.Scraper):
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape the NextUI pak list")
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ import bisect
|
||||
import re
|
||||
from collections.abc import Callable, Iterator
|
||||
|
||||
try:
|
||||
from .shell_launchers import is_feature_ref, split_ref
|
||||
except ImportError:
|
||||
from shell_launchers import is_feature_ref, split_ref # type: ignore[no-redef]
|
||||
from .shell_launchers import is_feature_ref, split_ref
|
||||
|
||||
GENERATORS = "emulatorLauncher/Generators"
|
||||
FEATURES = ".emulationstation/es_features.cfg"
|
||||
|
||||
@@ -14,30 +14,17 @@ import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
from .batocera_scraper import SYSTEM_SLUG_MAP as BATOCERA_SLUGS
|
||||
from .retrobat_launchers import SOURCE_FILES as LAUNCHER_FILES
|
||||
from .retrobat_launchers import extract_launchers
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
from batocera_scraper import SYSTEM_SLUG_MAP as BATOCERA_SLUGS
|
||||
from retrobat_launchers import SOURCE_FILES as LAUNCHER_FILES
|
||||
from retrobat_launchers import extract_launchers
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
from .batocera_scraper import SYSTEM_SLUG_MAP as BATOCERA_SLUGS
|
||||
from .retrobat_launchers import SOURCE_FILES as LAUNCHER_FILES
|
||||
from .retrobat_launchers import extract_launchers
|
||||
|
||||
PLATFORM_NAME = "retrobat"
|
||||
PLATFORM_FILE = Path(__file__).resolve().parents[2] / "platforms" / "retrobat.yml"
|
||||
|
||||
@@ -23,10 +23,7 @@ from collections.abc import Callable
|
||||
from pathlib import PurePosixPath
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
from .retropie_launchers import Launcher, LauncherPatternMissing, merge_records, source_ref
|
||||
except ImportError:
|
||||
from retropie_launchers import Launcher, LauncherPatternMissing, merge_records, source_ref
|
||||
from .retropie_launchers import Launcher, LauncherPatternMissing, merge_records, source_ref
|
||||
|
||||
BIOS = "$bios_path"
|
||||
PLACEHOLDER = "RETRODECKBIOSDIR"
|
||||
|
||||
@@ -27,6 +27,7 @@ Verification logic (api_data_processing.sh:289-405):
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
@@ -34,29 +35,22 @@ import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from .retrodeck_launchers import extract_launchers
|
||||
except ImportError:
|
||||
if not __package__:
|
||||
# Allow running directly: python scripts/scraper/retrodeck_scraper.py
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
from scraper.base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from scraper.retrodeck_launchers import extract_launchers
|
||||
importlib.import_module("scraper")
|
||||
__package__ = "scraper"
|
||||
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_branch_head,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
github_headers,
|
||||
requirement_entry,
|
||||
)
|
||||
from .retrodeck_launchers import extract_launchers
|
||||
|
||||
PLATFORM_NAME = "retrodeck"
|
||||
COMPONENTS_REPO = "RetroDECK/components"
|
||||
@@ -578,10 +572,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from scraper.base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape RetroDECK BIOS requirements")
|
||||
|
||||
|
||||
@@ -29,16 +29,10 @@ import tarfile
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
try:
|
||||
from .base_scraper import BaseScraper, BiosRequirement, fetch_branch_head
|
||||
from .retropie_launchers import SCRIPTMODULES
|
||||
from .retropie_launchers import SECTIONS as _SCRIPT_SECTIONS
|
||||
from .retropie_launchers import extract_launchers
|
||||
except ImportError:
|
||||
from base_scraper import BaseScraper, BiosRequirement, fetch_branch_head
|
||||
from retropie_launchers import SCRIPTMODULES
|
||||
from retropie_launchers import SECTIONS as _SCRIPT_SECTIONS
|
||||
from retropie_launchers import extract_launchers
|
||||
from .base_scraper import BaseScraper, BiosRequirement, fetch_branch_head
|
||||
from .retropie_launchers import SCRIPTMODULES
|
||||
from .retropie_launchers import SECTIONS as _SCRIPT_SECTIONS
|
||||
from .retropie_launchers import extract_launchers
|
||||
|
||||
PLATFORM_NAME = "retropie"
|
||||
|
||||
@@ -189,10 +183,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape the RetroPie package list")
|
||||
|
||||
|
||||
@@ -16,32 +16,18 @@ import re
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
|
||||
try:
|
||||
from .configgen_launchers import Launcher
|
||||
from .shell_launchers import config_placement, evidence_fields
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
Link,
|
||||
RepoTree,
|
||||
Script,
|
||||
Setting,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
except ImportError:
|
||||
from configgen_launchers import Launcher
|
||||
from shell_launchers import config_placement, evidence_fields # type: ignore[no-redef]
|
||||
from shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
Link,
|
||||
RepoTree,
|
||||
Script,
|
||||
Setting,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
from .configgen_launchers import Launcher
|
||||
from .shell_launchers import config_placement, evidence_fields
|
||||
from .shell_launchers import (
|
||||
LauncherPatternMissing,
|
||||
Link,
|
||||
RepoTree,
|
||||
Script,
|
||||
Setting,
|
||||
describe_keys,
|
||||
settings,
|
||||
source_ref,
|
||||
)
|
||||
|
||||
ROCKNIX = "projects/ROCKNIX"
|
||||
DEVICES = f"{ROCKNIX}/devices"
|
||||
|
||||
@@ -17,26 +17,15 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
md5_field,
|
||||
requirement_entry,
|
||||
)
|
||||
from .rocknix_launchers import extract_launchers
|
||||
from .shell_launchers import RepoTree
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
md5_field,
|
||||
requirement_entry,
|
||||
)
|
||||
from rocknix_launchers import extract_launchers
|
||||
from shell_launchers import RepoTree
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_github_latest_version,
|
||||
md5_field,
|
||||
requirement_entry,
|
||||
)
|
||||
from .rocknix_launchers import extract_launchers
|
||||
from .shell_launchers import RepoTree
|
||||
|
||||
PLATFORM_NAME = "rocknix"
|
||||
|
||||
@@ -321,10 +310,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
def main() -> None:
|
||||
"""Entry point."""
|
||||
try:
|
||||
from .base_scraper import scraper_cli
|
||||
except ImportError:
|
||||
from base_scraper import scraper_cli
|
||||
from .base_scraper import scraper_cli
|
||||
|
||||
scraper_cli(Scraper, "Scrape ROCKNIX BIOS requirements")
|
||||
|
||||
|
||||
@@ -26,22 +26,13 @@ import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
try:
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
except ImportError:
|
||||
from base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
from .base_scraper import (
|
||||
BaseScraper,
|
||||
BiosRequirement,
|
||||
fetch_bytes,
|
||||
fetch_github_latest_version,
|
||||
requirement_entry,
|
||||
)
|
||||
|
||||
PLATFORM_NAME = "romm"
|
||||
|
||||
|
||||
@@ -15,12 +15,8 @@ import re
|
||||
from collections.abc import Callable, Iterable
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
try:
|
||||
from .base_scraper import fetch_bytes, github_headers
|
||||
from .configgen_launchers import LauncherShapeError
|
||||
except ImportError:
|
||||
from base_scraper import fetch_bytes, github_headers
|
||||
from configgen_launchers import LauncherShapeError
|
||||
from .base_scraper import fetch_bytes, github_headers
|
||||
from .configgen_launchers import LauncherShapeError
|
||||
|
||||
NAME = r"[A-Za-z_][A-Za-z0-9_]*"
|
||||
# A single-quoted "$" is literal: it is carried as this mark through expansion.
|
||||
|
||||
@@ -24,23 +24,16 @@ from datetime import datetime, timezone
|
||||
import yaml
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..amberelec_scraper import BUILDS_OF, ES_SYSTEMS_TEMPLATE, RUNNERS
|
||||
from ..base_scraper import fetch_bytes
|
||||
from ..batocera_scraper import _not_cores
|
||||
from ..es_emulators import es_cores, xml_systems
|
||||
|
||||
PLATFORM_NAME = "amberelec"
|
||||
|
||||
RAW_BASE = "https://raw.githubusercontent.com/AmberELEC/AmberELEC/{ref}"
|
||||
META_MK = "packages/amberelec/package.mk"
|
||||
|
||||
try:
|
||||
from ..amberelec_scraper import BUILDS_OF, ES_SYSTEMS_TEMPLATE, RUNNERS
|
||||
from ..base_scraper import fetch_bytes
|
||||
from ..batocera_scraper import _not_cores
|
||||
from ..es_emulators import es_cores, xml_systems
|
||||
except ImportError:
|
||||
from scraper.amberelec_scraper import BUILDS_OF, ES_SYSTEMS_TEMPLATE, RUNNERS
|
||||
from scraper.base_scraper import fetch_bytes
|
||||
from scraper.batocera_scraper import _not_cores
|
||||
from scraper.es_emulators import es_cores, xml_systems
|
||||
|
||||
_DEVICE_RE = re.compile(
|
||||
r"^(\w+):\n\tDEVICE=(\w+) ARCH=(\w+) \./scripts/build_distro$", re.MULTILINE
|
||||
)
|
||||
|
||||
@@ -30,14 +30,10 @@ import yaml
|
||||
from safeparse import yaml_load_upstream
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..base_scraper import github_headers
|
||||
|
||||
PLATFORM_NAME = "batocera"
|
||||
|
||||
try:
|
||||
from ..base_scraper import github_headers
|
||||
except ImportError:
|
||||
from scraper.base_scraper import github_headers
|
||||
|
||||
_TARGET_FLAG_RE = re.compile(r"^(BR2_PACKAGE_BATOCERA_TARGET_\w+)=y", re.MULTILINE)
|
||||
|
||||
# The images a target flag builds, each a board directory whose last segment
|
||||
|
||||
@@ -35,6 +35,12 @@ from typing import NamedTuple
|
||||
import yaml
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
from ..batocera_scraper import _not_cores
|
||||
from ..emuelec_scraper import (
|
||||
BUILDS_OF, ES_SYSTEMS_TEMPLATE, PORTS_TEMPLATE, RUNNERS, port_engines, with_ports,
|
||||
)
|
||||
from ..es_emulators import SystemEmulators, es_cores
|
||||
|
||||
PLATFORM_NAME = "emuelec"
|
||||
|
||||
@@ -45,21 +51,6 @@ META_MK = "packages/sx05re/emuelec/package.mk"
|
||||
OPTIONS = "distributions/EmuELEC/options"
|
||||
ES_MK = "packages/sx05re/emuelec-emulationstation/package.mk"
|
||||
|
||||
try:
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
from ..batocera_scraper import _not_cores
|
||||
from ..emuelec_scraper import (
|
||||
BUILDS_OF, ES_SYSTEMS_TEMPLATE, PORTS_TEMPLATE, RUNNERS, port_engines, with_ports,
|
||||
)
|
||||
from ..es_emulators import SystemEmulators, es_cores
|
||||
except ImportError:
|
||||
from scraper.base_scraper import fetch_bytes, github_headers
|
||||
from scraper.batocera_scraper import _not_cores
|
||||
from scraper.emuelec_scraper import (
|
||||
BUILDS_OF, ES_SYSTEMS_TEMPLATE, PORTS_TEMPLATE, RUNNERS, port_engines, with_ports,
|
||||
)
|
||||
from scraper.es_emulators import SystemEmulators, es_cores
|
||||
|
||||
_ASSET_RE = re.compile(r"^EmuELEC-(?P<device>[A-Za-z0-9-]+)\.(?P<arch>[a-z0-9_]+)-")
|
||||
|
||||
# The metapackage, line for line. Each rule below transcribes these lines;
|
||||
|
||||
@@ -21,6 +21,7 @@ from datetime import datetime, timezone
|
||||
import yaml
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
|
||||
PLATFORM_NAME = "lakka"
|
||||
|
||||
@@ -29,11 +30,6 @@ RAW_BASE = "https://raw.githubusercontent.com/" + REPO + "/{tag}"
|
||||
API_BASE = "https://api.github.com/repos/" + REPO
|
||||
CORES_MK = "packages/lakka/libretro_cores/package.mk"
|
||||
|
||||
try:
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
except ImportError:
|
||||
from scraper.base_scraper import fetch_bytes, github_headers
|
||||
|
||||
_IF_RE = re.compile(r"^(if|elif)\s+\[\s+(.*?)\s+\];?\s*(?:then)?\s*$")
|
||||
_TEST_RE = re.compile(r'^(!\s+)?"\$\{?(\w+)\}?"\s*(=|!=)\s*"?([^"\s]*)"?$')
|
||||
_SET_RE = re.compile(r"^\s*-([nz])\s+\"\$\{?(\w+)\}?\"\s*$")
|
||||
|
||||
@@ -22,6 +22,8 @@ from datetime import datetime, timezone
|
||||
import yaml
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..base_scraper import fetch_bytes
|
||||
from ..recalbox_scraper import SYSTEMS_TREE_URL, Scraper as PlatformScraper, board_cores
|
||||
|
||||
PLATFORM_NAME = "recalbox"
|
||||
|
||||
@@ -33,13 +35,6 @@ DEFCONFIG_URL = "https://gitlab.com/recalbox/recalbox/-/raw/{tag}/configs/{name}
|
||||
_DEFCONFIG_RE = re.compile(r"^recalbox-(\w+)_defconfig$")
|
||||
_ENABLED_RE = re.compile(r"^(BR2_PACKAGE_\w+)=y\s*$", re.MULTILINE)
|
||||
|
||||
try:
|
||||
from ..base_scraper import fetch_bytes
|
||||
from ..recalbox_scraper import SYSTEMS_TREE_URL, Scraper as PlatformScraper, board_cores
|
||||
except ImportError:
|
||||
from scraper.base_scraper import fetch_bytes
|
||||
from scraper.recalbox_scraper import SYSTEMS_TREE_URL, Scraper as PlatformScraper, board_cores
|
||||
|
||||
|
||||
def enabled_packages(defconfig: str) -> set[str]:
|
||||
"""The Buildroot packages a defconfig turns on."""
|
||||
|
||||
@@ -23,6 +23,8 @@ from datetime import datetime, timezone
|
||||
import yaml
|
||||
|
||||
from . import BaseTargetScraper
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
from ..rocknix_scraper import standalone_emulators
|
||||
|
||||
PLATFORM_NAME = "rocknix"
|
||||
|
||||
@@ -31,13 +33,6 @@ GITHUB_API = "https://api.github.com/repos/ROCKNIX/distribution/contents"
|
||||
EMULATORS_MK = "projects/ROCKNIX/packages/virtual/emulators/package.mk"
|
||||
DEVICES_DIR = "projects/ROCKNIX/devices"
|
||||
|
||||
try:
|
||||
from ..base_scraper import fetch_bytes, github_headers
|
||||
from ..rocknix_scraper import standalone_emulators
|
||||
except ImportError:
|
||||
from scraper.base_scraper import fetch_bytes, github_headers
|
||||
from scraper.rocknix_scraper import standalone_emulators
|
||||
|
||||
# `NAME="a b \
|
||||
# c"` or `NAME+=" a b"`, continuation lines joined first.
|
||||
_ASSIGN_RE = re.compile(r'^\s*(?:\[[^\]]*\]\s*&&\s*)?(\w+)(\+?=)"([^"]*)"', re.MULTILINE)
|
||||
|
||||
Reference in new issue
Block a user