refactor: drop dead scraper import fallbacks

This commit is contained in:
Abdessamad Derraz committed 2026-11-17 07:23:39 +01:00
1 parent 3e732fd57e
commit 34eee3f087
27 files changed
+233 -424

No files matched your search

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