mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
chore: merge main for the ruff config
This commit is contained in:
commit
4e9f7673a2
186 files changed
+1001
-1058
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
|
||||
# the site's build rewrites this line there (scripts/sitebootstrap.py).
|
||||
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
$defaultInstallSha256 = "4b8e2e8e5343dbf75f6c9b089993cce3b7f64ad1e7a5a6c91993a07ec9674bc6"
|
||||
$defaultInstallSha256 = "5ff90f40cfcdab22fd1056f9a40ea2193541155eaf4c1ab48c8d16ac1f230c44"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
$maximumInstallerBytes = 8MB
|
||||
|
||||
+18
-18
@@ -353,7 +353,7 @@ def _enable_ansi() -> bool:
|
||||
if os.name != "nt":
|
||||
return True
|
||||
try:
|
||||
import ctypes # noqa: PLC0415
|
||||
import ctypes
|
||||
|
||||
kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
||||
handle = kernel32.GetStdHandle(-11)
|
||||
@@ -2857,7 +2857,7 @@ def _read_registry(key: str, value: str) -> str | None:
|
||||
"""A string value of the Windows registry, read natively or, under WSL,
|
||||
through reg.exe. None when the key, the value or the means is missing."""
|
||||
if os.name == "nt":
|
||||
import winreg # noqa: PLC0415
|
||||
import winreg
|
||||
|
||||
hive, _, subkey = key.partition("\\")
|
||||
roots = {"HKCU": winreg.HKEY_CURRENT_USER, "HKLM": winreg.HKEY_LOCAL_MACHINE}
|
||||
@@ -3476,7 +3476,7 @@ def did_you_mean(
|
||||
by the letters and digits of a typed name, the names it stands for
|
||||
here, suggested instead of the close ones.
|
||||
"""
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
by_key: dict[str, str] = {}
|
||||
for name in known:
|
||||
@@ -4624,7 +4624,7 @@ _RAW_ERRORS = threading.Event()
|
||||
|
||||
def _default_ca_present() -> bool:
|
||||
"""Whether the certificates this Python reads by default exist."""
|
||||
import ssl # noqa: PLC0415
|
||||
import ssl
|
||||
|
||||
paths = ssl.get_default_verify_paths()
|
||||
for value in (os.environ.get("SSL_CERT_FILE"), paths.cafile, paths.openssl_cafile):
|
||||
@@ -5221,7 +5221,7 @@ def canonical_region(raw: str) -> str:
|
||||
key = raw.strip().lower()
|
||||
key = REGION_ALIASES.get(key, key)
|
||||
if key not in REGIONS:
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
close = difflib.get_close_matches(key, [*REGION_ALIASES, *REGIONS], n=3, cutoff=0.5)
|
||||
hint = f" Close matches: {', '.join(close)}." if close else ""
|
||||
@@ -10150,7 +10150,7 @@ def standalone_plan(
|
||||
RetroArch had no tree to copy from. The first list that holds a name for
|
||||
a folder serves it.
|
||||
"""
|
||||
from fnmatch import fnmatch # noqa: PLC0415
|
||||
from fnmatch import fnmatch
|
||||
|
||||
plan: dict[Path, dict[str, dict]] = {}
|
||||
for manifest in manifests:
|
||||
@@ -10674,7 +10674,7 @@ def _drive_not_removable(mount: Path) -> bool:
|
||||
False where it says nothing."""
|
||||
if os.name == "nt":
|
||||
try:
|
||||
import ctypes # noqa: PLC0415
|
||||
import ctypes
|
||||
kind = ctypes.windll.kernel32.GetDriveTypeW(str(mount)) # type: ignore[attr-defined]
|
||||
except (AttributeError, OSError):
|
||||
return False
|
||||
@@ -14463,7 +14463,7 @@ def fat32_drive(folder: Path) -> bool:
|
||||
probe = probe.parent
|
||||
if os.name == "nt":
|
||||
try:
|
||||
import ctypes # noqa: PLC0415
|
||||
import ctypes
|
||||
root = ctypes.create_unicode_buffer(261)
|
||||
kind = ctypes.create_unicode_buffer(261)
|
||||
kernel = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
||||
@@ -21766,7 +21766,7 @@ def tui_blocker(
|
||||
return (f"the terminal is {cols}x{rows}, smaller than "
|
||||
f"{TUI_MIN_COLS}x{TUI_MIN_ROWS}")
|
||||
if os.name == "nt":
|
||||
import importlib # noqa: PLC0415
|
||||
import importlib
|
||||
|
||||
try:
|
||||
importlib.import_module("msvcrt")
|
||||
@@ -21776,7 +21776,7 @@ def tui_blocker(
|
||||
return "this console does not draw escape sequences (Windows 10 or later does)"
|
||||
return ""
|
||||
try:
|
||||
import termios # noqa: PLC0415
|
||||
import termios
|
||||
except ImportError:
|
||||
return "this Python has no termios to read keys"
|
||||
try:
|
||||
@@ -25002,7 +25002,7 @@ def _tui_key(state: TuiState, key: TuiKey) -> list[tuple]:
|
||||
step = 1 if focus == 0 else -1
|
||||
order = list(range(focus, -1, -1) if step < 0 else range(focus, len(rows)))
|
||||
if wrap and moved:
|
||||
order += range(last, focus, -1) if step < 0 else range(0, focus)
|
||||
order += range(last, focus, -1) if step < 0 else range(focus)
|
||||
focus = next((index for index in order if rows[index].action != "heading"),
|
||||
max(0, min(state.focus.get(screen, 0), last)))
|
||||
state.focus[screen] = focus
|
||||
@@ -28963,7 +28963,7 @@ class _TuiTerminal:
|
||||
|
||||
def enter(self) -> None:
|
||||
if os.name != "nt":
|
||||
import termios # noqa: PLC0415
|
||||
import termios
|
||||
|
||||
# Entered again after a stop, the mode to go back to stays the
|
||||
# one found the first time.
|
||||
@@ -28993,7 +28993,7 @@ class _TuiTerminal:
|
||||
self.write(_SCREEN_OFF)
|
||||
finally:
|
||||
if self.saved is not None:
|
||||
import termios # noqa: PLC0415
|
||||
import termios
|
||||
|
||||
saved, self.saved = self.saved, None
|
||||
termios.tcsetattr(self.fd, termios.TCSADRAIN, saved)
|
||||
@@ -29036,7 +29036,7 @@ class _TuiTerminal:
|
||||
if self.ended:
|
||||
time.sleep(timeout)
|
||||
return []
|
||||
import select # noqa: PLC0415
|
||||
import select
|
||||
|
||||
if not select.select([self.fd], [], [], timeout)[0]:
|
||||
# A paste whose end never came, after a second of silence.
|
||||
@@ -29063,7 +29063,7 @@ class _TuiTerminal:
|
||||
return self.decoder.feed(self.input.decode(data))
|
||||
|
||||
def _console_keys(self, timeout: float) -> list[TuiKey]:
|
||||
import msvcrt # noqa: PLC0415
|
||||
import msvcrt
|
||||
|
||||
end = time.monotonic() + timeout
|
||||
keys: list[TuiKey] = []
|
||||
@@ -29497,7 +29497,7 @@ def run_tui(args: argparse.Namespace) -> int:
|
||||
if terminating["signal"] and state.screen == "result":
|
||||
# The result is printed in the terminal on the way out.
|
||||
state.exit_code = state.code if state.code is not None else 1
|
||||
except Exception as exc: # noqa: BLE001
|
||||
except Exception as exc:
|
||||
if flags["term"] or _closed_terminal(exc, terminal):
|
||||
# The window closed under a screen that was changing, or the
|
||||
# SIGCONT that comes with its SIGHUP put the screen back: the
|
||||
@@ -29587,7 +29587,7 @@ def _terminal_gone(terminal: _TuiTerminal) -> bool:
|
||||
error is taken as it reads."""
|
||||
if os.name == "nt":
|
||||
return True
|
||||
import termios # noqa: PLC0415
|
||||
import termios
|
||||
|
||||
try:
|
||||
termios.tcgetattr(terminal.fd)
|
||||
@@ -29642,7 +29642,7 @@ def _tui_cleanup(
|
||||
"""Stop the child, put the terminal and the signal handlers back: what failed."""
|
||||
failures: tuple = (OSError, ValueError)
|
||||
if os.name != "nt":
|
||||
import termios # noqa: PLC0415
|
||||
import termios
|
||||
|
||||
failures += (termios.error,)
|
||||
problems: list[str] = []
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
|
||||
# curl or wget stop on a cut transfer before the hash is read: the site's
|
||||
# build rewrites this line there (scripts/sitebootstrap.py).
|
||||
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
DEFAULT_INSTALL_SHA256="4b8e2e8e5343dbf75f6c9b089993cce3b7f64ad1e7a5a6c91993a07ec9674bc6"
|
||||
DEFAULT_INSTALL_SHA256="5ff90f40cfcdab22fd1056f9a40ea2193541155eaf4c1ab48c8d16ac1f230c44"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
MAX_INSTALLER_BYTES=8388608
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{
|
||||
"dest": "roms/ports/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1384488,
|
||||
"sha256": "4b8e2e8e5343dbf75f6c9b089993cce3b7f64ad1e7a5a6c91993a07ec9674bc6",
|
||||
"size": 1384197,
|
||||
"sha256": "5ff90f40cfcdab22fd1056f9a40ea2193541155eaf4c1ab48c8d16ac1f230c44",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1438113,
|
||||
"sha256": "388342648dc84cadfae52e4c550349a30016bbd9a880d946749e96fc593dd9fb"
|
||||
"size": 1437822,
|
||||
"sha256": "c82fdd8134e2579f5fcff020a3b1b97135bb73ee8893b4aaa892022b31792021"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1384488,
|
||||
"sha256": "4b8e2e8e5343dbf75f6c9b089993cce3b7f64ad1e7a5a6c91993a07ec9674bc6",
|
||||
"size": 1384197,
|
||||
"sha256": "5ff90f40cfcdab22fd1056f9a40ea2193541155eaf4c1ab48c8d16ac1f230c44",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1384488,
|
||||
"sha256": "4b8e2e8e5343dbf75f6c9b089993cce3b7f64ad1e7a5a6c91993a07ec9674bc6",
|
||||
"size": 1384197,
|
||||
"sha256": "5ff90f40cfcdab22fd1056f9a40ea2193541155eaf4c1ab48c8d16ac1f230c44",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -76,3 +76,36 @@ cache_dir = "tmp/mypy_cache"
|
||||
baseline_path = "mypy-baseline.txt"
|
||||
ignore_categories = ["note"]
|
||||
sort_baseline = true
|
||||
|
||||
# CI runs this rule set over every Python file (validate.yml, pr_checks.py).
|
||||
# C901 and the PLR limits hold function size: a function past them is split
|
||||
# by stage, not exempted.
|
||||
[tool.ruff]
|
||||
target-version = "py39"
|
||||
line-length = 120
|
||||
extend-exclude = ["bios", "tmp", "website", ".cache", "dist", "data"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "W", "B", "C90", "SIM", "PERF", "UP", "RET", "PIE", "PLR09", "PLW1510", "RUF100"]
|
||||
ignore = [
|
||||
"E501", # long lines are wrapped by hand where it reads better
|
||||
"UP006", "UP007", "UP035", "UP045", # install.py keeps 3.8 spellings
|
||||
"SIM300", # an ALL_CAPS name is not always a constant (_SYSTEM_ROOT)
|
||||
"SIM108", # a ternary is not always clearer than an if block
|
||||
"PERF203", # try in a loop is the per-item error report
|
||||
"RET504", "RET505", "RET506", "RET508",
|
||||
]
|
||||
|
||||
[tool.ruff.lint.mccabe]
|
||||
max-complexity = 15
|
||||
|
||||
[tool.ruff.lint.pylint]
|
||||
max-branches = 15
|
||||
max-statements = 60
|
||||
max-args = 8
|
||||
max-returns = 10
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"install.py" = ["UP"]
|
||||
# Shell fixtures inside string literals keep the tabs the real files have.
|
||||
"tests/test_launchers_*.py" = ["E101"]
|
||||
@@ -46,7 +46,7 @@ from typing import BinaryIO
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
from torrentzip import Source as Readable
|
||||
from torrentzip import write_torrentzip, zlib_ng_version # noqa: E402
|
||||
from torrentzip import write_torrentzip, zlib_ng_version
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
ARCHIVES_FILE = REPO_ROOT / "recipes" / "archives.json"
|
||||
@@ -105,7 +105,7 @@ def ledger_text(records: dict[str, dict]) -> str:
|
||||
|
||||
|
||||
def write_ledger(records: dict[str, dict], path: Path = ARCHIVES_FILE) -> bool:
|
||||
from artifacts import write_if_changed # noqa: PLC0415
|
||||
from artifacts import write_if_changed
|
||||
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
return write_if_changed(str(path), ledger_text(records))
|
||||
@@ -236,7 +236,7 @@ def container_pins(platforms_dir: str, emulators_dir: str) -> dict[str, set[str]
|
||||
archive md5 is the composite of its members (``zip_digest: composite``,
|
||||
Bios.cpp:64-68): neither pins the container bytes.
|
||||
"""
|
||||
from common import ( # noqa: PLC0415
|
||||
from common import (
|
||||
list_registered_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
@@ -269,8 +269,8 @@ def recipe_index(emulators_dir: str, recipes_dir: str) -> dict[MemberList, set[s
|
||||
Matching on the member list, not the archive name, credits a DAT that
|
||||
knows the set under another name (``aga.zip`` is MAME's ``isa_aga``).
|
||||
"""
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from romset_recipes import collect_recipes, load_dat_recipes # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
from romset_recipes import collect_recipes, load_dat_recipes
|
||||
|
||||
index: dict[MemberList, set[str]] = defaultdict(set)
|
||||
profiles = load_emulator_profiles(emulators_dir, skip_aliases=False)
|
||||
|
||||
@@ -86,8 +86,8 @@ def find_missing(config: dict, db: dict) -> list[dict]:
|
||||
checks them inside the zip and holds them, and saw none of the files
|
||||
the cores need that no platform lists.
|
||||
"""
|
||||
from nativemode import reads_file_contents # noqa: PLC0415
|
||||
from verify import Status, verify_platform # noqa: PLC0415
|
||||
from nativemode import reads_file_contents
|
||||
from verify import Status, verify_platform
|
||||
|
||||
result = verify_platform(config, db)
|
||||
hashed = reads_file_contents(config.get("verification_mode", "existence"))
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ class Context:
|
||||
def check_subject(subject: str, body: str = "") -> list[str]:
|
||||
"""What the repository's commit rules refuse in this message, checked
|
||||
when the job list loads instead of two hours into the job."""
|
||||
from commit_rules import problems # noqa: PLC0415
|
||||
from commit_rules import problems
|
||||
|
||||
return problems(f"{subject}\n\n{body}" if body else subject)
|
||||
|
||||
|
||||
@@ -141,12 +141,12 @@ def release_pack_labels(root: Path = REPO_ROOT) -> dict[str, str]:
|
||||
refuses a pack whose name does not spell the platform, so a platform
|
||||
outside these groups has no pack to copy, whatever its file list.
|
||||
"""
|
||||
from common import ( # noqa: PLC0415
|
||||
from common import (
|
||||
group_identical_platforms,
|
||||
list_release_pack_platforms,
|
||||
load_platform_config,
|
||||
)
|
||||
from generate_pack import _name_part, _platform_pack_stem # noqa: PLC0415
|
||||
from generate_pack import _name_part, _platform_pack_stem
|
||||
|
||||
platforms_dir = str(root / "platforms")
|
||||
pool = list_release_pack_platforms(platforms_dir)
|
||||
@@ -178,7 +178,7 @@ def build_archive(name: str, output: Path, root: Path = REPO_ROOT) -> Path:
|
||||
)
|
||||
# The packs' member writer: imported here, as it loads the whole
|
||||
# pack builder, which a caller reading ARCHIVES does not need.
|
||||
from generate_pack import _add_pack_member # noqa: PLC0415
|
||||
from generate_pack import _add_pack_member
|
||||
|
||||
members = archive_members(name, root)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@@ -119,7 +119,7 @@ def main() -> int:
|
||||
parser.add_argument("--json", action="store_true", help="print the list as JSON")
|
||||
parser.add_argument("--strict", action="store_true", help="exit 1 while a file is listed")
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["db", "emulators_dir", "platforms_dir", "install_dir"])
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ Usage:
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@@ -51,9 +52,7 @@ def load_tracked_entries(
|
||||
|
||||
Returns {decoded_zip_name: (key, source_url)}.
|
||||
"""
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
if importlib.util.find_spec("yaml") is None:
|
||||
print("Error: PyYAML required", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
with open(registry_path) as f:
|
||||
|
||||
+20
-20
@@ -49,11 +49,11 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
import export_native # noqa: E402
|
||||
import pin_installer # noqa: E402
|
||||
import refresh_data_dirs # noqa: E402
|
||||
import upstream # noqa: E402
|
||||
from common import ( # noqa: E402
|
||||
import export_native
|
||||
import pin_installer
|
||||
import refresh_data_dirs
|
||||
import upstream
|
||||
from common import (
|
||||
InputMissing,
|
||||
apply_target_overrides,
|
||||
list_registered_platforms,
|
||||
@@ -65,11 +65,11 @@ from common import ( # noqa: E402
|
||||
write_text_atomic,
|
||||
yaml_load,
|
||||
)
|
||||
from exporter import discover_exporters # noqa: E402
|
||||
from exporter.baseline import build_native_model # noqa: E402
|
||||
from scripts.scraper import game_dat_importer # noqa: E402
|
||||
from scripts.scraper.redump_dat_scraper import fetch_snapshot # noqa: E402
|
||||
from scripts.scraper.targets import discover_target_scrapers # noqa: E402
|
||||
from exporter import discover_exporters
|
||||
from exporter.baseline import build_native_model
|
||||
from scripts.scraper import game_dat_importer
|
||||
from scripts.scraper.redump_dat_scraper import fetch_snapshot
|
||||
from scripts.scraper.targets import discover_target_scrapers
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
CORE_INFO_REPO = "https://github.com/libretro/libretro-core-info"
|
||||
@@ -876,7 +876,7 @@ def core_info_blobs(cache_dir: str, offline: bool) -> dict[str, str] | None:
|
||||
repo = upstream.parse_repo(CORE_INFO_REPO)
|
||||
if repo is None:
|
||||
return None
|
||||
payload = upstream._api( # noqa: SLF001
|
||||
payload = upstream._api(
|
||||
f"{repo.api_base}/repos/{repo.slug}/contents?per_page=100",
|
||||
cache_dir,
|
||||
offline,
|
||||
@@ -1046,7 +1046,7 @@ def _check_buildbot_system() -> Finding:
|
||||
The registry entries are refreshed above. An asset published since, or
|
||||
one the buildbot no longer serves, is only seen by reading its .index.
|
||||
"""
|
||||
import check_buildbot_system # noqa: PLC0415
|
||||
import check_buildbot_system
|
||||
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
report = check_buildbot_system.check(
|
||||
@@ -1094,7 +1094,7 @@ def _game_catalogs(source: str) -> list[dict]:
|
||||
def _no_intro_asset_date(cache_dir: str, offline: bool) -> str:
|
||||
"""The day the mirror last rebuilt its No-Intro pack, empty if unlisted."""
|
||||
repo = upstream.parse_repo(NO_INTRO_MIRROR)
|
||||
payload = upstream._api( # noqa: SLF001
|
||||
payload = upstream._api(
|
||||
f"{repo.api_base}/repos/{repo.slug}/releases/tags/{NO_INTRO_RELEASE}",
|
||||
cache_dir,
|
||||
offline,
|
||||
@@ -1146,8 +1146,8 @@ def redump_datfile_version(code: str) -> str:
|
||||
request = urllib.request.Request(url, method="HEAD", headers={"User-Agent": "retrobios/1.0"})
|
||||
with urllib.request.urlopen(request, timeout=60) as response:
|
||||
disposition = response.headers.get("Content-Disposition", "")
|
||||
named = game_dat_importer._DISPOSITION.search(disposition) # noqa: SLF001
|
||||
match = game_dat_importer._REDUMP_FILE.match(named["file"]) if named else None # noqa: SLF001
|
||||
named = game_dat_importer._DISPOSITION.search(disposition)
|
||||
match = game_dat_importer._REDUMP_FILE.match(named["file"]) if named else None
|
||||
if not match:
|
||||
raise ValueError(f"{url} names no datfile")
|
||||
return f"{match['date']} {match['time']}"
|
||||
@@ -1225,7 +1225,7 @@ def _check_tosec(offline: bool) -> Finding:
|
||||
if offline:
|
||||
return Finding("catalogs", "tosec", SKIPPED, local=imported, detail="offline")
|
||||
try:
|
||||
html = upstream._http_text(TOSEC_DOWNLOADS) # noqa: SLF001
|
||||
html = upstream._http_text(TOSEC_DOWNLOADS)
|
||||
except upstream.UpstreamError as exc:
|
||||
return Finding("catalogs", "tosec", UNKNOWN, local=imported, detail=str(exc))
|
||||
latest = tosec_latest_pack(html or "")
|
||||
@@ -1297,7 +1297,7 @@ def _check_fbneo(cache_dir: str, offline: bool) -> Finding:
|
||||
if offline:
|
||||
return Finding("catalogs", "fbneo recipes", SKIPPED, local=imported, detail="offline")
|
||||
repo = upstream.parse_repo(FBNEO_REPO)
|
||||
listing = upstream._api( # noqa: SLF001
|
||||
listing = upstream._api(
|
||||
f"{repo.api_base}/repos/{repo.slug}/contents/dats",
|
||||
cache_dir,
|
||||
offline,
|
||||
@@ -1386,7 +1386,7 @@ def specifier_allows(spec: str, version: str) -> bool:
|
||||
|
||||
|
||||
def pypi_latest(name: str) -> str | None:
|
||||
payload = upstream._http_json(PYPI_URL.format(name=name)) # noqa: SLF001
|
||||
payload = upstream._http_json(PYPI_URL.format(name=name))
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
info = payload.get("info") or {}
|
||||
@@ -1403,7 +1403,7 @@ def parse_npm_pins(text: str) -> dict[str, str]:
|
||||
|
||||
|
||||
def npm_latest(name: str) -> str | None:
|
||||
payload = upstream._http_json(NPM_URL.format(name=name)) # noqa: SLF001
|
||||
payload = upstream._http_json(NPM_URL.format(name=name))
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
return str(payload.get("version") or "") or None
|
||||
@@ -1518,7 +1518,7 @@ def check_source_paths(profiles: dict) -> Finding:
|
||||
or a pinned tree the record lacks, means a pin moved or a profile was
|
||||
added and `sitesources.py --fetch` was not run after it. Every tree a run
|
||||
tries is recorded, read or not, so a lacking one was never tried."""
|
||||
import sitesources # noqa: PLC0415
|
||||
import sitesources
|
||||
|
||||
pinned = {
|
||||
sitesources.tree_key(repo, pin)
|
||||
|
||||
+23
-24
@@ -12,6 +12,7 @@ from collections import Counter
|
||||
import argparse
|
||||
import filecmp
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
@@ -106,7 +107,7 @@ def load_database(db_path: str) -> dict:
|
||||
except FileNotFoundError:
|
||||
# A mistyped --db beside the real database was told to rescan the
|
||||
# whole collection into a second file under the typo.
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
typed = Path(db_path)
|
||||
close = difflib.get_close_matches(
|
||||
@@ -235,8 +236,8 @@ def adler32_of(path: str, byteswap: bool = False) -> str:
|
||||
Dolphin swaps every 16-bit word of its DSP ROMs before hashing them
|
||||
(Common::swap16 in DSPLLE.cpp:LoadDSPRom).
|
||||
"""
|
||||
import struct # noqa: PLC0415
|
||||
import zlib # noqa: PLC0415
|
||||
import struct
|
||||
import zlib
|
||||
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
@@ -335,7 +336,7 @@ def declared_content_checks(file_entry: dict) -> set[str]:
|
||||
|
||||
@functools.lru_cache(maxsize=4096)
|
||||
def _romdir_verdict(path: str, size: int, mtime_ns: int, spec: str) -> bool:
|
||||
from romdir import romdir_accepts # noqa: PLC0415
|
||||
from romdir import romdir_accepts
|
||||
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
@@ -722,8 +723,8 @@ SHORT_LIST = 12
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def _gh_cli_token() -> str:
|
||||
"""What `gh auth token` prints, or "" when gh is absent or logged out."""
|
||||
import logging # noqa: PLC0415
|
||||
import subprocess # noqa: PLC0415
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
try:
|
||||
@@ -775,7 +776,7 @@ def suggest_names(
|
||||
`listed` is how many entries the listing shows when `available` also
|
||||
holds aliases of them.
|
||||
"""
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
total = len(available) if listed is None else listed
|
||||
close = sorted({m for name in typed
|
||||
@@ -845,7 +846,7 @@ def require_platform(name: str, platforms_dir: str = "platforms") -> None:
|
||||
)
|
||||
if os.path.exists(os.path.join(platforms_dir, f"{name}.yml")):
|
||||
return
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
known = list_registered_platforms(platforms_dir)
|
||||
close = difflib.get_close_matches(name, known, n=1)
|
||||
@@ -2485,9 +2486,7 @@ def load_emulator_profiles(
|
||||
}
|
||||
_emulator_profiles_cache[cache_key] = profiles
|
||||
return profiles
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
if importlib.util.find_spec("yaml") is None:
|
||||
# Every consumer reads {} as "this repo documents no emulator", which
|
||||
# is what a broken install looks like from the outside: zero coverage,
|
||||
# no gap, nothing to fix.
|
||||
@@ -3003,7 +3002,7 @@ def standalone_set(config: dict) -> set[str]:
|
||||
for core in entry.get("cores") or []
|
||||
}
|
||||
if names - {n for n in names if n.startswith(CORE_DIR_PREFIX)}:
|
||||
from launchers import executed_files, handed_directories # noqa: PLC0415
|
||||
from launchers import executed_files, handed_directories
|
||||
|
||||
handed = handed_directories(config)
|
||||
# The record's position travels too: a search list is read in order.
|
||||
@@ -3023,7 +3022,7 @@ def standalone_set(config: dict) -> set[str]:
|
||||
if f.get("name")
|
||||
}
|
||||
# The machines a record offers under its systems, by normalized id.
|
||||
from launchers import native_systems # noqa: PLC0415
|
||||
from launchers import native_systems
|
||||
|
||||
natives = native_systems(config)
|
||||
names |= {
|
||||
@@ -3059,7 +3058,7 @@ def merged_standalone_set(configs: Iterable[dict]) -> set[str]:
|
||||
|
||||
def _handed(standalone_cores: Iterable[str]) -> list:
|
||||
"""The directories a standalone set carries, as launchers built them."""
|
||||
from launchers import HandedDirectory # noqa: PLC0415
|
||||
from launchers import HandedDirectory
|
||||
|
||||
found = []
|
||||
for tag in standalone_cores:
|
||||
@@ -3103,7 +3102,7 @@ def entry_launch_systems(entry: dict, index: Mapping[str, set[str]]) -> frozense
|
||||
|
||||
def _executed(standalone_cores: Iterable[str]) -> list:
|
||||
"""The files a standalone set's launchers execute, as launchers read them."""
|
||||
from launchers import ExecutedFile # noqa: PLC0415
|
||||
from launchers import ExecutedFile
|
||||
|
||||
found = []
|
||||
for tag in standalone_cores:
|
||||
@@ -3198,7 +3197,7 @@ def standalone_destination(
|
||||
layout = standalone_layout_path(entry, profile)
|
||||
if layout is None or not bindings:
|
||||
return None
|
||||
from launchers import bound_path # noqa: PLC0415
|
||||
from launchers import bound_path
|
||||
|
||||
return bound_path(layout, bindings)
|
||||
|
||||
@@ -3211,7 +3210,7 @@ def standalone_bindings_for(
|
||||
|
||||
``systems`` are those the entry is launched for (entry_launch_systems).
|
||||
"""
|
||||
from launchers import directory_handles, pool_folders, standalone_bindings # noqa: PLC0415
|
||||
from launchers import directory_handles, pool_folders, standalone_bindings
|
||||
|
||||
declared = directory_handles(profile)
|
||||
pools = pool_folders(profile)
|
||||
@@ -3332,7 +3331,7 @@ def _build_layouts(
|
||||
|
||||
# The layout folders a search setting stands for (standalone_pools):
|
||||
# bound, the launcher passes the setting and the default is not read.
|
||||
from launchers import pool_folders as _pool_folders # noqa: PLC0415
|
||||
from launchers import pool_folders as _pool_folders
|
||||
|
||||
pool_folders = {v.strip("/") for v in _pool_folders(profile).values()} - {""}
|
||||
|
||||
@@ -3428,7 +3427,7 @@ def _branch_holds(branch: str, board: str) -> bool:
|
||||
variable, _, pattern = branch.strip().partition(" ")
|
||||
if variable != "DEVICE" or not pattern.strip():
|
||||
return True
|
||||
import fnmatch # noqa: PLC0415
|
||||
import fnmatch
|
||||
|
||||
return any(
|
||||
fnmatch.fnmatchcase(board.upper(), p.strip().upper()) for p in pattern.split("|")
|
||||
@@ -3539,7 +3538,7 @@ def content_folder_tags(config: dict) -> set[str]:
|
||||
boards = content_folder_boards(config)
|
||||
target = config.get(TARGET_KEY)
|
||||
pairs = {pair for pair, on in boards.items() if not target or on is None or target in on}
|
||||
from launchers import _roms_place # noqa: PLC0415
|
||||
from launchers import _roms_place
|
||||
|
||||
def place(folder: str) -> list:
|
||||
return list(_roms_place(config, folder) or ())
|
||||
@@ -3712,7 +3711,7 @@ def content_layout(
|
||||
# path with stand for these: libretro MAME hands MAME
|
||||
# <system>/mame/bios unless the content's command line names
|
||||
# another (retro_init.cpp Set_Path_Option, execute_game_cmd).
|
||||
from launchers import pool_folders # noqa: PLC0415
|
||||
from launchers import pool_folders
|
||||
|
||||
pools = set(pool_folders({"standalone_pools": view.get("libretro_pools")}).values())
|
||||
for f in files:
|
||||
@@ -4279,7 +4278,7 @@ SYSTEM_ALIASES: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _norm_system_id(sid: str) -> str:
|
||||
"""Normalize system ID for cross-platform matching.
|
||||
|
||||
@@ -4605,7 +4604,7 @@ def declared_root(config: dict) -> str:
|
||||
list also names folders beside the BIOS one states it as
|
||||
core_destination: EmuELEC's ports/ entries are a quarter of its list.
|
||||
"""
|
||||
if config.get("base_destination", None) != "":
|
||||
if config.get("base_destination") != "":
|
||||
return ""
|
||||
if config.get("core_destination"):
|
||||
return str(config["core_destination"])
|
||||
@@ -4820,7 +4819,7 @@ def build_target_cores_cache(
|
||||
|
||||
def _unknown_target_message(target: str, platforms: list[str], platforms_dir: str) -> str:
|
||||
"""A target no platform has, with the closest names any of them knows."""
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
targets_dir = os.path.join(platforms_dir, "targets")
|
||||
owners: dict[str, list[str]] = {}
|
||||
|
||||
@@ -1455,7 +1455,7 @@ def load_oracle(path: Path | None) -> tuple[dict, dict | None]:
|
||||
"""The oracle file's data and its identity, or nothing without a file."""
|
||||
if path is None or not path.is_file():
|
||||
return {}, None
|
||||
import yaml # noqa: PLC0415
|
||||
import yaml
|
||||
|
||||
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
||||
try:
|
||||
@@ -1469,7 +1469,7 @@ def default_emulator(core_file: Path, library_name: str | None) -> str:
|
||||
"""The profile whose cores: names the .so, else the library name as a slug."""
|
||||
stem = core_file.name.split(".")[0].removesuffix("_libretro")
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
owners = sorted(key for key, profile in load_emulator_profiles(str(ROOT / "emulators")).items()
|
||||
if stem == key or stem in (profile.get("cores") or []))
|
||||
@@ -1485,7 +1485,7 @@ def default_emulator(core_file: Path, library_name: str | None) -> str:
|
||||
def default_subject(record: dict) -> str:
|
||||
"""A slug shared by the reruns of one test: a check by its claim and
|
||||
method, a run or bench by its inputs."""
|
||||
from measurement_records import canonical, sha256_hex, slugify # noqa: PLC0415
|
||||
from measurement_records import canonical, sha256_hex, slugify
|
||||
|
||||
check = record.get("check")
|
||||
if check:
|
||||
@@ -1501,7 +1501,7 @@ def default_subject(record: dict) -> str:
|
||||
def write_record(directory: Path, full: dict) -> tuple[Path, dict]:
|
||||
"""Append the record, with its id, to its emulator's .jsonl. Returns the
|
||||
file and the record as written."""
|
||||
from measurement_records import line_text, parse_lines, records_path, seal # noqa: PLC0415
|
||||
from measurement_records import line_text, parse_lines, records_path, seal
|
||||
|
||||
sealed = seal(full)
|
||||
lines = directory / records_path(sealed["emulator"])
|
||||
@@ -1546,7 +1546,7 @@ def _probe(args: argparse.Namespace) -> int:
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
load_after = load_average()
|
||||
first = variants[0]["repetitions"][0]
|
||||
from measurement_records import RECORD_VERSION # noqa: PLC0415
|
||||
from measurement_records import RECORD_VERSION
|
||||
|
||||
record: dict = {
|
||||
"record_version": RECORD_VERSION,
|
||||
@@ -1622,7 +1622,7 @@ def rejudged(record: dict, data: dict, identity: dict | None, now: str) -> dict
|
||||
record's. The verdicts, their evidence, bios_used and inputs.oracle are
|
||||
computed again, and judged_at and judged_by say when and by what.
|
||||
"""
|
||||
import copy # noqa: PLC0415
|
||||
import copy
|
||||
|
||||
# Another probe (standalone_probe, pack_probe) judges with its own rules.
|
||||
if record.get("record_version", 0) < 4 or record["frontend"].get("script") != "scripts/core_probe.py":
|
||||
@@ -1656,8 +1656,8 @@ def rejudged(record: dict, data: dict, identity: dict | None, now: str) -> dict
|
||||
return out
|
||||
|
||||
|
||||
def RECORD_VERSION_NOW() -> int: # noqa: N802
|
||||
from measurement_records import RECORD_VERSION # noqa: PLC0415
|
||||
def RECORD_VERSION_NOW() -> int:
|
||||
from measurement_records import RECORD_VERSION
|
||||
|
||||
return RECORD_VERSION
|
||||
|
||||
@@ -1665,7 +1665,7 @@ def RECORD_VERSION_NOW() -> int: # noqa: N802
|
||||
def rejudge_records(args: argparse.Namespace) -> int:
|
||||
"""Append, for each live record whose judgement the oracle now gives
|
||||
otherwise, the record judged again, superseding it."""
|
||||
from measurement_records import line_text, live, read_records, records_path, seal # noqa: PLC0415
|
||||
from measurement_records import line_text, live, read_records, records_path, seal
|
||||
|
||||
root = Path(args.record)
|
||||
data, identity = load_oracle(Path(args.oracle) if args.oracle else DEFAULT_ORACLE)
|
||||
|
||||
@@ -1187,9 +1187,7 @@ class _NameHolder:
|
||||
base = name.rsplit("/", 1)[-1]
|
||||
found: tuple[str, bool] | None = None
|
||||
stem = suffixed_stem(base)
|
||||
if base in self.by_name or any(map(self._entry_held, self.exact.get(base, []))):
|
||||
found = (base, True)
|
||||
elif stem is not None and any(map(self._entry_held, self.exact.get(stem, []))):
|
||||
if base in self.by_name or any(map(self._entry_held, self.exact.get(base, []))) or stem is not None and any(map(self._entry_held, self.exact.get(stem, []))):
|
||||
found = (base, True)
|
||||
else:
|
||||
path, _status = resolve_local_file(
|
||||
@@ -1554,7 +1552,7 @@ def main() -> None:
|
||||
"--list-emulators", action="store_true", help="List available emulators"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["emulators_dir", "platforms_dir", "db"])
|
||||
if args.list_emulators:
|
||||
|
||||
@@ -82,7 +82,7 @@ def crc32_combine(crc1: int, crc2: int, len2: int) -> int:
|
||||
return _gf2_times(_shift_operator(len2), crc1) ^ crc2
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _byte_shift(power: int) -> tuple[int, ...]:
|
||||
"""The operator for 2**power zero bytes appended, as zlib squares it:
|
||||
three squarings of the one-bit operator give one byte, and each power
|
||||
@@ -95,7 +95,7 @@ def _byte_shift(power: int) -> tuple[int, ...]:
|
||||
return tuple(operator)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _shift_operator(len2: int) -> tuple[int, ...]:
|
||||
"""The linear map zlib applies to crc(A) for len2 bytes appended.
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ class StaleTruth(ValueError):
|
||||
"""The truth file no longer describes the profiles it was built from."""
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _truth_sources(platforms_dir: str) -> tuple[dict, dict, dict | None]:
|
||||
"""Registry, profiles and database, as generate_truth reads them."""
|
||||
registry_path = Path(platforms_dir) / "_registry.yml"
|
||||
|
||||
@@ -421,13 +421,13 @@ class Exporter(BaseExporter):
|
||||
continue
|
||||
key = _note_key(line)
|
||||
if not key[0]:
|
||||
if 0 <= hash_at and "[" in line[:hash_at]:
|
||||
if hash_at >= 0 and "[" in line[:hash_at]:
|
||||
pending.append(line[hash_at:].strip())
|
||||
continue
|
||||
if pending:
|
||||
leading[key] = pending
|
||||
pending = []
|
||||
if 0 <= hash_at and hash_at > line.index(key[0]):
|
||||
if hash_at >= 0 and hash_at > line.index(key[0]):
|
||||
trailing[key] = line[hash_at:].rstrip()
|
||||
return trailing, leading
|
||||
|
||||
|
||||
@@ -46,10 +46,7 @@ def _declared_hashes(entry: dict) -> dict[str, set[str]]:
|
||||
def _accepts(accepted: set[str], declared: dict[str, set[str]]) -> bool:
|
||||
"""True when the hashes a profile entry accepts, the members of its
|
||||
archive included, hold one the platform entry declares."""
|
||||
for values in declared.values():
|
||||
if values & accepted:
|
||||
return True
|
||||
return False
|
||||
return any(values & accepted for values in declared.values())
|
||||
|
||||
|
||||
def _contradicts(profile_entry: dict, declared: dict[str, set[str]]) -> bool:
|
||||
|
||||
@@ -89,7 +89,7 @@ class Exporter(BaseExporter):
|
||||
and self._known_platform(fe.native_system)
|
||||
)
|
||||
|
||||
def writable(self, fe: NativeFile, require: str = "") -> bool: # noqa: ARG002
|
||||
def writable(self, fe: NativeFile, require: str = "") -> bool:
|
||||
"""What RomM already ships stays. The conditions gate additions.
|
||||
|
||||
An entry of theirs that could never verify is still theirs, and the
|
||||
|
||||
@@ -21,7 +21,7 @@ import urllib.parse
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import upstream # noqa: E402
|
||||
import upstream
|
||||
|
||||
# Commits listed per page and the most pages walked: a data file older than
|
||||
# 2 000 commits on its own path is not one a platform list still pins.
|
||||
|
||||
@@ -247,7 +247,7 @@ def main() -> int:
|
||||
help="profiles the rules are checked against (default emulators)")
|
||||
parser.add_argument("--json", action="store_true", help="print the summary as JSON")
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["regions", "extras", "headers", "emulators_dir"])
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from common import ( # noqa: E402
|
||||
list_registered_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
native_layer,
|
||||
@@ -584,8 +583,9 @@ def folder_systems(setups: dict[str, dict]) -> dict[str, list[str]]:
|
||||
return {name: sorted(systems) for name, systems in sorted(names.items())}
|
||||
|
||||
|
||||
def render(output: Path = OUTPUT, inputs: Inputs = Inputs()) -> tuple[dict[Path, str], dict]:
|
||||
def render(output: Path = OUTPUT, inputs: Inputs | None = None) -> tuple[dict[Path, str], dict]:
|
||||
"""Every published file's text, keyed by its path, and the coverage."""
|
||||
inputs = inputs or Inputs()
|
||||
resolver = SystemResolver.from_repo(inputs.emulators, inputs.platforms)
|
||||
profiles = Profiles(load_emulator_profiles(inputs.emulators), resolver)
|
||||
arcade = build_arcade(inputs.games / "arcade")
|
||||
|
||||
@@ -232,8 +232,8 @@ def line_menu() -> str:
|
||||
prints it for the RetroArch list (install/retroarch.json): the very
|
||||
function line mode runs, its questions answered here. The page carried
|
||||
a copy typed by hand, whose keys and counts drifted from the installer."""
|
||||
import io # noqa: PLC0415
|
||||
from unittest import mock # noqa: PLC0415
|
||||
import io
|
||||
from unittest import mock
|
||||
|
||||
manifest = json.loads((ROOT / "install" / "retroarch.json").read_text(encoding="utf-8"))
|
||||
files = [*manifest["files"], *(manifest.get("case_variants") or [])]
|
||||
@@ -284,7 +284,7 @@ class _ListHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def __init__(self, *args: object, **kwargs: object) -> None:
|
||||
super().__init__(*args, directory=str(ROOT), **kwargs)
|
||||
|
||||
def do_GET(self) -> None: # noqa: N802
|
||||
def do_GET(self) -> None:
|
||||
if not re.fullmatch(r"/install/[a-z0-9_-]+\.json", self.path):
|
||||
self.send_error(404)
|
||||
return
|
||||
@@ -317,7 +317,7 @@ SMALL_LIST = {
|
||||
|
||||
|
||||
def write_small_list(path: Path) -> None:
|
||||
import hashlib # noqa: PLC0415
|
||||
import hashlib
|
||||
|
||||
files = []
|
||||
for dest, (data, systems, regions, cores) in SMALL_LIST.items():
|
||||
@@ -339,9 +339,9 @@ def _child(spec: dict) -> int:
|
||||
data tree of a landed run reports its bytes written without fetching
|
||||
them, and a held run finds every file and tree in place. The counts,
|
||||
sizes and words are the installer's own."""
|
||||
import concurrent.futures # noqa: PLC0415
|
||||
import socket # noqa: PLC0415
|
||||
from unittest import mock # noqa: PLC0415
|
||||
import concurrent.futures
|
||||
import socket
|
||||
from unittest import mock
|
||||
|
||||
real_connect = socket.create_connection
|
||||
|
||||
@@ -382,7 +382,7 @@ def _child(spec: dict) -> int:
|
||||
patches += [
|
||||
mock.patch.object(_install, "detect_platforms",
|
||||
lambda _os: [(spec["platform"], Path(spec["card"]))]),
|
||||
mock.patch.object(_install, "_mounted_cards", lambda: []),
|
||||
mock.patch.object(_install, "_mounted_cards", list),
|
||||
]
|
||||
if spec.get("landed"):
|
||||
patches.append(mock.patch.object(_install, "_download_one", landed))
|
||||
|
||||
@@ -3997,7 +3997,7 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
|
||||
# Manifest generation (JSON inventory for install.py)
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _registered(repo_root: str) -> frozenset[str]:
|
||||
"""The paths a repository's .gitignore registers as release assets, read
|
||||
by the parser the fetcher and the release check use, once per root."""
|
||||
@@ -4149,7 +4149,7 @@ def _profile_copies(
|
||||
the emulator, else the shortest path. DuckStation's ps2_scph50006.bin
|
||||
sits at the BIOS root and under pcsx2/bios/ for the libretro PS2 cores.
|
||||
"""
|
||||
from fnmatch import fnmatch # noqa: PLC0415
|
||||
from fnmatch import fnmatch
|
||||
|
||||
taken: list[tuple[str, str, str, bool]] = []
|
||||
for copy in declared:
|
||||
@@ -5704,7 +5704,7 @@ def _offered_boards(
|
||||
pairs = content_folder_boards(config)
|
||||
if all(on is None for on in pairs.values()):
|
||||
return {}
|
||||
from launchers import _roms_place # noqa: PLC0415
|
||||
from launchers import _roms_place
|
||||
|
||||
by_key: dict[str, set[str]] = {}
|
||||
for name, claimants in upstream_profile_index(profiles).items():
|
||||
@@ -6240,7 +6240,7 @@ from packextras import ( # noqa: E402,F401
|
||||
)
|
||||
|
||||
|
||||
from packreadme import ( # noqa: E402,F401
|
||||
from packreadme import ( # noqa: E402
|
||||
_build_readme,
|
||||
_build_agnostic_rename_readme,
|
||||
save_place,
|
||||
|
||||
@@ -37,7 +37,6 @@ from common import (
|
||||
unique_emulator_profiles,
|
||||
write_if_changed,
|
||||
)
|
||||
from nativemode import check_label
|
||||
import archive_build
|
||||
import release_record
|
||||
from siteguides import PACKAGE_COMMAND, install_command
|
||||
@@ -50,7 +49,7 @@ from verify import verify_platform
|
||||
def _installer_words() -> object:
|
||||
"""install.py read as a module, for the words its screen shows: the
|
||||
README named a line menu the one-liner never opens."""
|
||||
import importlib.util # noqa: PLC0415
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.spec_from_file_location(
|
||||
"install", Path(__file__).resolve().parent.parent / "install.py")
|
||||
@@ -591,7 +590,6 @@ def archive_line(counts: dict[str, int]) -> str:
|
||||
|
||||
def generate_readme(db: dict, platforms_dir: str, db_path: str = "database.json") -> str:
|
||||
total_files = db.get("total_files", 0)
|
||||
total_size = db.get("total_size", 0)
|
||||
ts = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
platform_names = list_registered_platforms(platforms_dir)
|
||||
@@ -616,16 +614,6 @@ def generate_readme(db: dict, platforms_dir: str, db_path: str = "database.json"
|
||||
/ len(profile_files)) if profile_files else 0)
|
||||
closed_count = sum(1 for prof in profiles.values()
|
||||
if str(prof.get("upstream") or "").startswith("closed"))
|
||||
comp = compute_composition(db)
|
||||
missing_total = len(set().union(*(c["missing_names"] for c in coverages.values())))
|
||||
# The entries marked `unsourceable:` are never served by name, so a
|
||||
# homonym cannot take their place: retail game data, per-user keys, slots
|
||||
# the user fills. Each stays an acquisition target with its reason, and
|
||||
# is counted apart from the files still to be found.
|
||||
unsourceable_total = len(
|
||||
set().union(*(c["unsourceable_names"] for c in coverages.values()))
|
||||
)
|
||||
acquirable_total = missing_total - unsourceable_total
|
||||
|
||||
system_ids = system_index(profiles)
|
||||
|
||||
|
||||
+34
-39
@@ -38,7 +38,7 @@ from pathlib import Path
|
||||
from typing import TypeVar
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from sitecollection import ( # noqa: E402
|
||||
from sitecollection import (
|
||||
_copy_places, _group_by_manufacturer, _profiles_in,
|
||||
_profiles_on_disk, _slug, collection_paths,
|
||||
)
|
||||
@@ -77,7 +77,6 @@ from nativemode import check_label, digest_algorithm, reads_file_contents
|
||||
|
||||
yaml = require_yaml()
|
||||
from generate_readme import (
|
||||
compute_coverage,
|
||||
platform_coverages,
|
||||
NO_PACK,
|
||||
asset_links,
|
||||
@@ -86,7 +85,6 @@ from generate_readme import (
|
||||
demo_facts,
|
||||
download_links,
|
||||
extract_notes,
|
||||
extract_targets,
|
||||
release_totals,
|
||||
)
|
||||
from provenance_report import build_report, distinct_missing, profile_needs
|
||||
@@ -109,8 +107,6 @@ from siteguides import (
|
||||
Guide,
|
||||
HandheldGuide,
|
||||
HandheldSystem,
|
||||
FENCE_TITLES,
|
||||
INSTALL_BASE,
|
||||
INSTALL_PS1,
|
||||
INSTALL_SH,
|
||||
PACKAGE_COMMAND,
|
||||
@@ -118,7 +114,6 @@ from siteguides import (
|
||||
TRUST_ITEMS,
|
||||
detected_systems as _detected_systems,
|
||||
fence,
|
||||
folder_list,
|
||||
install_command,
|
||||
setup_count,
|
||||
platform_args,
|
||||
@@ -626,7 +621,7 @@ def _pack_version(pack_name: str, platforms: list[str]) -> str:
|
||||
Read past the platform part the builder writes, not at the last
|
||||
underscore: AmberELEC_prerelease-20261019_1835 read as 1835.
|
||||
"""
|
||||
from generate_pack import platform_pack_prefix # noqa: PLC0415
|
||||
from generate_pack import platform_pack_prefix
|
||||
|
||||
stem = pack_name.removesuffix("_BIOS_Pack.zip")
|
||||
prefix = platform_pack_prefix(
|
||||
@@ -1081,7 +1076,7 @@ def _release_pack_platforms() -> frozenset[str]:
|
||||
return _release_packs_in(str(siteinputs.current().platforms))
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _release_packs_in(platforms_dir: str) -> frozenset[str]:
|
||||
return frozenset(list_release_pack_platforms(platforms_dir))
|
||||
|
||||
@@ -2810,7 +2805,7 @@ def platform_dat(manifest: dict, db: dict, member_digests: dict[str, dict[str, s
|
||||
|
||||
def _logiqx(name: str, description: str, games: dict[str, list[dict]], generated_at: str) -> str:
|
||||
"""Games of roms as a Logiqx datafile, each rom's `_rom` its name."""
|
||||
import xml.etree.ElementTree as ET # noqa: PLC0415
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
root = ET.Element("datafile")
|
||||
header = ET.SubElement(root, "header")
|
||||
@@ -3261,7 +3256,7 @@ def _front_matter(markdown: str) -> dict:
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _sha1_by_prefix(db_path: str) -> dict[str, str]:
|
||||
return {sha1[:12]: sha1 for sha1 in load_database(db_path)["files"]}
|
||||
|
||||
@@ -3584,7 +3579,7 @@ def _collection_sha1_by_path() -> dict[str, str]:
|
||||
return _sha1_by_path_in(str(siteinputs.current().db))
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _sha1_by_path_in(db_path: str) -> dict[str, str]:
|
||||
with open(db_path, encoding="utf-8") as handle:
|
||||
files = json.load(handle).get("files", {})
|
||||
@@ -3727,7 +3722,7 @@ def _copy_hash(algorithm: str, value: str | list) -> str:
|
||||
"""A declared hash cut to SHORT_HASH characters on a button that copies
|
||||
it whole. A list of accepted values (Recalbox) copies its first. Outside
|
||||
a form a button submits nothing, so it carries no type."""
|
||||
from hashing import parse_hash_list # noqa: PLC0415
|
||||
from hashing import parse_hash_list
|
||||
|
||||
values = parse_hash_list(value)
|
||||
if not values:
|
||||
@@ -4126,7 +4121,7 @@ def _profiles_by_core_name() -> dict[str, list[str]]:
|
||||
return _core_names_in(str(siteinputs.current().emulators))
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _profiles_with_page(emulators_dir: str) -> frozenset[str]:
|
||||
"""The profiles the site writes a page for: no alias, no test core."""
|
||||
profiles = _profiles_in(emulators_dir, skip_aliases=True)
|
||||
@@ -4135,7 +4130,7 @@ def _profiles_with_page(emulators_dir: str) -> frozenset[str]:
|
||||
)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _core_names_in(emulators_dir: str) -> dict[str, list[str]]:
|
||||
profiles = _profiles_in(emulators_dir, skip_aliases=True)
|
||||
with_page = _profiles_with_page(emulators_dir)
|
||||
@@ -5065,8 +5060,8 @@ def _data_member_digests(
|
||||
whose copy in the tree's local cache has the sha1 the manifest records.
|
||||
The manifests carry sha1 alone: the MD5 of Dolphin's ApprovedInis.json
|
||||
found nothing although the pack ships it."""
|
||||
from common import load_data_dir_registry # noqa: PLC0415
|
||||
from hashing import compute_hashes # noqa: PLC0415
|
||||
from common import load_data_dir_registry
|
||||
from hashing import compute_hashes
|
||||
|
||||
if data_registry is None:
|
||||
data_registry = load_data_dir_registry(str(siteinputs.current().platforms))
|
||||
@@ -5361,7 +5356,7 @@ def _console_display(manufacturer: str, console: str) -> str:
|
||||
"""A console section's name as the reader looks for it: the heading
|
||||
system_name gives its id, or the folder alone under a program's top
|
||||
(Other, Arcade), where "Other mame" would name nothing."""
|
||||
from siterender import _PROGRAM_TOPS, _heading_name # noqa: PLC0415
|
||||
from siterender import _PROGRAM_TOPS, _heading_name
|
||||
|
||||
return console if manufacturer in _PROGRAM_TOPS else _heading_name(manufacturer, console)
|
||||
|
||||
@@ -5843,7 +5838,7 @@ def _fetch_url(path: str) -> str:
|
||||
large-files release asset when .gitignore keeps it out of git."""
|
||||
global _RELEASE_ASSET_NAMES
|
||||
if _RELEASE_ASSET_NAMES is None:
|
||||
from largefiles import ( # noqa: PLC0415
|
||||
from largefiles import (
|
||||
LARGE_FILES_RELEASE,
|
||||
asset_names,
|
||||
load_registered_paths,
|
||||
@@ -6502,7 +6497,7 @@ def system_install_choices(coverages: dict) -> dict[str, dict[str, list[tuple[st
|
||||
platform's install manifest records is offered: --system refuses any
|
||||
other name.
|
||||
"""
|
||||
from siterender import _page_by_norm # noqa: PLC0415
|
||||
from siterender import _page_by_norm
|
||||
|
||||
choices: dict[str, dict[str, list[tuple[str, str]]]] = {}
|
||||
for name, cov in sorted(coverages.items()):
|
||||
@@ -6670,7 +6665,7 @@ def _region_order() -> dict[str, int]:
|
||||
for every region is a region-free stand-in for the BIOS of each one:
|
||||
the PlayStation section opened on psxonpsp660.bin, which one emulator
|
||||
requires among the BIOS it accepts, above the scph files most read."""
|
||||
from region import REGION_TREE, WORLD # noqa: PLC0415
|
||||
from region import REGION_TREE, WORLD
|
||||
|
||||
ordered = []
|
||||
for parent, members in REGION_TREE.items():
|
||||
@@ -6710,7 +6705,7 @@ _SECTION_ENTRIES: dict[int, tuple[object, dict[tuple[str, str], list]]] = {}
|
||||
def _entries_by_section(consumers: FileConsumers) -> dict[tuple[str, str], list]:
|
||||
"""Each console section with the (sha1, emulator, entry, system) whose
|
||||
system leads to it, read once per build."""
|
||||
from siterender import system_section # noqa: PLC0415
|
||||
from siterender import system_section
|
||||
|
||||
cached = _SECTION_ENTRIES.get(id(consumers))
|
||||
if cached is not None and cached[0] is consumers:
|
||||
@@ -6876,7 +6871,7 @@ def _start_groups(
|
||||
the Mega CD BIOS for its Genesis), and one under Other is a single
|
||||
emulator's, its shaders and fonts. A file the emulator ships with is
|
||||
no file to fetch."""
|
||||
from siterender import _heading_name, _manufacturer_slug, system_name, system_section # noqa: PLC0415
|
||||
from siterender import _heading_name, _manufacturer_slug, system_name, system_section
|
||||
|
||||
here = (_manufacturer_slug(section[0]), section[1]) if section else None
|
||||
held = {str(f.get("sha1", "")) for f in files}
|
||||
@@ -7193,7 +7188,7 @@ def _group_start(group: _StartGroup, first_below: bool) -> list[tuple[str, str]]
|
||||
that run without it. The Game Boy opened on dmg_boot.bin, which Emux
|
||||
GB alone of 13 requires, under a home page that says the Game Boy
|
||||
needs no BIOS."""
|
||||
from region import _PARENT # noqa: PLC0415
|
||||
from region import _PARENT
|
||||
|
||||
def listed(names: list[str], below: bool = first_below) -> str:
|
||||
if len(names) <= START_WITH_NAMES:
|
||||
@@ -7429,7 +7424,7 @@ def arcade_board_sections(
|
||||
folders. Each board is recorded (siterender.record_board_section) before
|
||||
any page links one, and a system's install commands follow its link to
|
||||
the board's section. Call after reset_console_pages()."""
|
||||
from siterender import ( # noqa: PLC0415
|
||||
from siterender import (
|
||||
arcade_board,
|
||||
arcade_boards,
|
||||
archive_machine,
|
||||
@@ -7525,7 +7520,7 @@ def arcade_board_sections(
|
||||
def _boards_line(manufacturer: str, console: str) -> list[str]:
|
||||
"""The line of a section whose board sets went to the boards' pages:
|
||||
the Dreamcast folder holds NAOMI's and Atomiswave's."""
|
||||
from siterender import arcade_boards # noqa: PLC0415
|
||||
from siterender import arcade_boards
|
||||
|
||||
boards = _BOARDS_FROM.get((manufacturer, console))
|
||||
if not boards:
|
||||
@@ -7576,7 +7571,7 @@ def _part_weight() -> float:
|
||||
return SEARCH_WEIGHT.get("part", DEMOTED_WEIGHT)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _manifest_systems(platform: str) -> frozenset[str]:
|
||||
"""The system ids a platform's install manifest records: --system
|
||||
refuses any other."""
|
||||
@@ -7628,7 +7623,7 @@ def system_pages(
|
||||
(siterender.record_console_pages). An arcade board has a page of its
|
||||
own, systems/arcade-<board slug>/, under a heading of that id.
|
||||
"""
|
||||
from siterender import board_slug # noqa: PLC0415
|
||||
from siterender import board_slug
|
||||
|
||||
slug = _slug(manufacturer)
|
||||
installs = installs or {}
|
||||
@@ -7907,7 +7902,7 @@ def _named_system_link(sys_id: str, prefix: str = "") -> str:
|
||||
The emulator pages printed the id ("sony-playstation") where every
|
||||
other page says "Sony PlayStation". The id stays in the address only.
|
||||
"""
|
||||
from siterender import system_section # noqa: PLC0415
|
||||
from siterender import system_section
|
||||
|
||||
name = system_name(sys_id).replace("[", r"\[").replace("]", r"\]")
|
||||
section = system_section(sys_id)
|
||||
@@ -7938,7 +7933,7 @@ def _region_words(value: object, most: int = 0) -> str:
|
||||
"""A region: value in words. ``most`` caps the regions named, the rest
|
||||
counted: one Saturn BIOS serves seven."""
|
||||
raw = value if isinstance(value, list) else [value] if value else []
|
||||
from region import label # noqa: PLC0415
|
||||
from region import label
|
||||
|
||||
words = [_REGION_WORDS.get(str(r)) or label(str(r)) for r in raw]
|
||||
if most and len(words) > most:
|
||||
@@ -8082,7 +8077,7 @@ def comes_with_app(f: dict) -> bool:
|
||||
narrowed by ``mode`` is that build's alone: the other build reads its
|
||||
own entry, or nothing.
|
||||
"""
|
||||
from validation import installed_with_emulator # noqa: PLC0415
|
||||
from validation import installed_with_emulator
|
||||
|
||||
return installed_with_emulator(f)
|
||||
|
||||
@@ -8272,7 +8267,7 @@ def _build_file_links(pin_build: list[dict]) -> list[str]:
|
||||
"""Each platform build file that holds the revision, linked at the
|
||||
commit it was read at when the source record holds it. The prose of
|
||||
pin_frozen named the file as plain text."""
|
||||
from sitesources import _browse_repo, _source_permalink, tree_holds # noqa: PLC0415
|
||||
from sitesources import _browse_repo, tree_holds
|
||||
|
||||
links = []
|
||||
for build in pin_build:
|
||||
@@ -8629,7 +8624,7 @@ def _more_words(lines: list[str]) -> list[str]:
|
||||
def _short_hash_line(f: dict) -> str:
|
||||
"""The entry's strongest declared hash, cut to SHORT_HASH characters,
|
||||
with a copy button for the whole value. "" when it declares none."""
|
||||
from hashing import parse_hash_list # noqa: PLC0415
|
||||
from hashing import parse_hash_list
|
||||
|
||||
for field, label in (("sha1", "SHA1"), ("md5", "MD5"), ("sha256", "SHA256"), ("crc32", "CRC32")):
|
||||
values = parse_hash_list(f.get(field) or "")
|
||||
@@ -9002,7 +8997,7 @@ def install_commands(args: str = "", indent: str = "",
|
||||
def _installer() -> object:
|
||||
"""install.py, read as a module: the names `--emulator` accepts are its
|
||||
own (`emulator_names`)."""
|
||||
import importlib.util # noqa: PLC0415
|
||||
import importlib.util
|
||||
|
||||
spec = importlib.util.spec_from_file_location("install", _REPO_ROOT / "install.py")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
@@ -9567,7 +9562,7 @@ def _hash_spans(value: str | list, copy: bool = False) -> str:
|
||||
that only a profile declares were out of reach of the site search: it
|
||||
indexes text, and a pasted sha1 matched nothing.
|
||||
"""
|
||||
from hashing import parse_hash_list # noqa: PLC0415
|
||||
from hashing import parse_hash_list
|
||||
|
||||
return ", ".join(
|
||||
markup.hash_value(v, copy) for v in parse_hash_list(value)
|
||||
@@ -10625,7 +10620,7 @@ def _declared_hashes(config: dict, detail: dict) -> dict[str, list[str]]:
|
||||
and named neither: the reader could not look for the dump RetroDECK asks
|
||||
for, nor report the difference.
|
||||
"""
|
||||
from hashing import parse_hash_list # noqa: PLC0415
|
||||
from hashing import parse_hash_list
|
||||
|
||||
system = (config.get("systems") or {}).get(detail.get("system", "")) or {}
|
||||
for entry in system.get("files") or []:
|
||||
@@ -10946,8 +10941,8 @@ def reading_platforms(emu_name: str, profile: dict, name: str,
|
||||
"""Of the platforms running an emulator (name -> config), those whose
|
||||
build of it reads the entry: BlastEm's cdbios.bin is read by the
|
||||
standalone build only, and RetroBat hands that build other names."""
|
||||
from common import platform_layouts, standalone_set # noqa: PLC0415
|
||||
from validation import filter_files_by_mode, unread_on # noqa: PLC0415
|
||||
from common import platform_layouts, standalone_set
|
||||
from validation import filter_files_by_mode, unread_on
|
||||
|
||||
return {
|
||||
platform for platform, config in configs.items()
|
||||
@@ -12636,7 +12631,7 @@ def _generate(args: argparse.Namespace) -> None:
|
||||
_system_pages_from_data(manufacturers, coverages, db, profiles)
|
||||
)
|
||||
print(f" {len(_system_page_map)} system IDs mapped to pages")
|
||||
from siterender import link_coverage, system_ids # noqa: PLC0415
|
||||
from siterender import link_coverage, system_ids
|
||||
|
||||
print("Generating system pages...")
|
||||
|
||||
@@ -12961,7 +12956,7 @@ def _generate(args: argparse.Namespace) -> None:
|
||||
print(f"Removed {stale} page(s) nothing produced this run")
|
||||
|
||||
|
||||
from sitediagrams import local_images, prepare_page, unresolved_images # noqa: E402,F401
|
||||
from sitediagrams import local_images, prepare_page, unresolved_images # noqa: E402
|
||||
from sitewrite import ( # noqa: E402,F401
|
||||
_produced,
|
||||
_record,
|
||||
|
||||
+2
-2
@@ -132,10 +132,10 @@ def main() -> int:
|
||||
"--strict", action="store_true", help="exit non-zero when any is found"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["bios_dir"])
|
||||
from common import require_directory # noqa: PLC0415
|
||||
from common import require_directory
|
||||
|
||||
require_directory(args.bios_dir)
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from siteagents import INDEXNOW_FILE, INDEXNOW_KEY, SITE # noqa: E402
|
||||
from siteagents import INDEXNOW_FILE, INDEXNOW_KEY, SITE
|
||||
|
||||
HOST = "abdess.github.io"
|
||||
# What one IndexNow request accepts.
|
||||
|
||||
@@ -216,13 +216,12 @@ def _fetch_asset(
|
||||
for candidate, url in _asset_urls(name):
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "retrobios/1.0"})
|
||||
with urllib.request.urlopen(req, timeout=300) as resp:
|
||||
with open(tmp_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
with urllib.request.urlopen(req, timeout=300) as resp, open(tmp_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
downloaded = True
|
||||
break
|
||||
except (urllib.error.URLError, OSError, http.client.HTTPException) as exc:
|
||||
@@ -389,7 +388,7 @@ def _served_digests() -> dict[str, str]:
|
||||
f"{LARGE_FILES_RELEASE}"
|
||||
)
|
||||
headers = {"User-Agent": "retrobios/1.0", "Accept": "application/vnd.github+json"}
|
||||
from common import github_token # noqa: PLC0415 (common imports this module)
|
||||
from common import github_token
|
||||
|
||||
token = github_token()
|
||||
if token:
|
||||
|
||||
+11
-11
@@ -284,7 +284,7 @@ def config_target(record: dict) -> tuple[str, list[str]]:
|
||||
if "." not in head or head.startswith("<"):
|
||||
# The file is the one the record installs, named by its path or,
|
||||
# when a variable spells the path, by the config file it cites.
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref, ref_path # noqa: PLC0415
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref, ref_path
|
||||
|
||||
installed = str((record.get("installs") or {}).get("path") or "").rsplit("/", 1)[-1]
|
||||
cited = [
|
||||
@@ -392,7 +392,7 @@ def _file_matches(read_file: str, file: str, record: dict) -> bool:
|
||||
any file the launcher passes), a path, or the flag the launcher passes
|
||||
it with (amiberry's -f).
|
||||
"""
|
||||
from fnmatch import fnmatch # noqa: PLC0415
|
||||
from fnmatch import fnmatch
|
||||
|
||||
spelled = read_file.rsplit("/", 1)[-1].casefold()
|
||||
if file and fnmatch(file.casefold(), spelled):
|
||||
@@ -449,7 +449,7 @@ def config_evidence(
|
||||
values a menu offers: it goes in ``choices_from``, beside the code that
|
||||
writes the choice, and such a record needs (c) and (d) too.
|
||||
"""
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref # noqa: PLC0415
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref
|
||||
|
||||
cited = config_ref(str(record.get("source_ref") or ""))
|
||||
choices = str(record.get("choices_from") or "")
|
||||
@@ -503,13 +503,13 @@ _DEFAULT_PROFILES: dict[str, dict] | None = None
|
||||
|
||||
def _profiles_or_repo(profiles: Mapping[str, dict] | None) -> Mapping[str, dict]:
|
||||
"""The profiles given, else this repository's, read once."""
|
||||
global _DEFAULT_PROFILES # noqa: PLW0603
|
||||
global _DEFAULT_PROFILES
|
||||
if profiles is not None:
|
||||
return profiles
|
||||
if _DEFAULT_PROFILES is None:
|
||||
from pathlib import Path # noqa: PLC0415
|
||||
from pathlib import Path
|
||||
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
_DEFAULT_PROFILES = load_emulator_profiles(
|
||||
str(Path(__file__).resolve().parent.parent / "emulators")
|
||||
@@ -518,7 +518,7 @@ def _profiles_or_repo(profiles: Mapping[str, dict] | None) -> Mapping[str, dict]
|
||||
|
||||
|
||||
def _cites_config(record: dict) -> bool:
|
||||
from scraper.shell_launchers import config_ref # noqa: PLC0415
|
||||
from scraper.shell_launchers import config_ref
|
||||
|
||||
return bool(record.get("choices_from")) or bool(config_ref(str(record.get("source_ref") or "")))
|
||||
|
||||
@@ -887,7 +887,7 @@ def _roms_place(config: dict, path: str | None) -> Place | None:
|
||||
platform installs above its BIOS folder (AmberELEC), else the roms tree."""
|
||||
if path is None:
|
||||
return None
|
||||
from common import ROMS_ROOT, outer_layout # noqa: PLC0415
|
||||
from common import ROMS_ROOT, outer_layout
|
||||
|
||||
layout = outer_layout(config, ROMS_ROOT) or {}
|
||||
if "install_prefix" in layout:
|
||||
@@ -903,7 +903,7 @@ def folder_in_configs(directory: str, config: dict) -> str | None:
|
||||
(``configs_root.path``): Batocera's /userdata/system/configs, where its
|
||||
generators start shadPS4 from configs/shadps4.
|
||||
"""
|
||||
from common import CONFIGS_ROOT # noqa: PLC0415
|
||||
from common import CONFIGS_ROOT
|
||||
|
||||
return folder_in_root(directory, config, CONFIGS_ROOT)
|
||||
|
||||
@@ -915,7 +915,7 @@ def folder_in_roms(directory: str, config: dict) -> str | None:
|
||||
(``roms_root.path``): ROCKNIX's /storage/roms, which holds its BIOS
|
||||
folder and the folders its launchers run programs from.
|
||||
"""
|
||||
from common import ROMS_ROOT, outer_layout # noqa: PLC0415
|
||||
from common import ROMS_ROOT, outer_layout
|
||||
|
||||
spelled = directory.strip().rstrip("/")
|
||||
for variable in ROMS_ROOT_VARIABLES:
|
||||
@@ -929,7 +929,7 @@ def folder_in_roms(directory: str, config: dict) -> str | None:
|
||||
|
||||
def folder_in_root(directory: str, config: dict, root: str) -> str | None:
|
||||
"""A directory relative to an outer root's path, None outside it."""
|
||||
from common import outer_layout # noqa: PLC0415
|
||||
from common import outer_layout
|
||||
|
||||
roms = str((outer_layout(config, root) or {}).get("path") or "").rstrip("/")
|
||||
directory = directory.strip().rstrip("/")
|
||||
|
||||
@@ -27,7 +27,7 @@ def list_platforms() -> list[str]:
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(allow_abbrev=False, description="List available platforms")
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, [])
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ def build_card(card: Path) -> None:
|
||||
|
||||
|
||||
class QuietHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def log_message(self, format: str, *args: object) -> None: # noqa: A002
|
||||
def log_message(self, format: str, *args: object) -> None:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -1324,10 +1324,6 @@ def _collect_emulator_extras(
|
||||
extras_prefix = placement.prefix
|
||||
is_slug_based = placement.slug_based
|
||||
|
||||
# Use strict YAML names (no DB alias enrichment) so that files known
|
||||
# under an alias still get packed at the emulator's expected path.
|
||||
yaml_names = platform_declarations(config, db, enrich=False)
|
||||
|
||||
if undeclared is None:
|
||||
undeclared = undeclared_report(
|
||||
config, emulators_dir, db, emu_profiles, target_cores, include_all
|
||||
@@ -1454,8 +1450,8 @@ def _collect_emulator_extras(
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
for f in profile.get("files", []):
|
||||
for layout, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
for f in layout.get("files", []):
|
||||
fname = f.get("name", "")
|
||||
if not fname:
|
||||
continue
|
||||
@@ -1524,17 +1520,17 @@ def _collect_emulator_extras(
|
||||
"destination": dest,
|
||||
"required": f.get("required", False),
|
||||
"hle_fallback": f.get("hle_fallback", False),
|
||||
"source_emulator": profile.get("emulator", emu_name),
|
||||
"source_emulator": layout.get("emulator", emu_name),
|
||||
"source_profile": emu_name,
|
||||
# The key the gap report gives the same entry.
|
||||
"source_name": fname,
|
||||
"source_path": raw,
|
||||
"category": f.get("category", "bios"),
|
||||
"source_system": f.get("system"),
|
||||
"source_systems": entry_system_ids(f, profile),
|
||||
"source_systems": entry_system_ids(f, layout),
|
||||
"region": f.get("region"),
|
||||
"selection_slot": f.get("selection_slot"),
|
||||
**set_fields(f, profile),
|
||||
**set_fields(f, layout),
|
||||
}
|
||||
# The same identity the first pass carries: without it the copy
|
||||
# resolves on its name alone and a same-named file of another
|
||||
|
||||
@@ -40,7 +40,7 @@ import zipfile
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _file_sha1(path: str) -> str:
|
||||
"""SHA-1 of a cached data-directory file, read once per run."""
|
||||
digest = hashlib.sha1()
|
||||
|
||||
+21
-21
@@ -331,7 +331,7 @@ def _match_key(label: str) -> set[str]:
|
||||
def release_pack_keys(platforms_dir: str = "platforms") -> set[str]:
|
||||
"""Comparable identities of the platforms --all builds a pack for: their
|
||||
registry ids and display names, normalized as _match_key does."""
|
||||
from common import list_release_pack_platforms, load_platform_config # noqa: PLC0415
|
||||
from common import list_release_pack_platforms, load_platform_config
|
||||
|
||||
keys: set[str] = set()
|
||||
for name in list_release_pack_platforms(platforms_dir):
|
||||
@@ -446,9 +446,9 @@ def _tree_members(
|
||||
platform: str, platforms_dir: str, emulators_dir: str = "emulators",
|
||||
) -> dict[str, int]:
|
||||
"""Archive path -> size of every file the platform's data trees can add."""
|
||||
import generate_pack # noqa: PLC0415
|
||||
from common import load_emulator_profiles, load_platform_config # noqa: PLC0415
|
||||
from packpaths import _flat # noqa: PLC0415
|
||||
import generate_pack
|
||||
from common import load_emulator_profiles, load_platform_config
|
||||
from packpaths import _flat
|
||||
|
||||
config = load_platform_config(platform, platforms_dir)
|
||||
base_dest = config.get("base_destination", "")
|
||||
@@ -488,8 +488,8 @@ def check_pack_destinations(
|
||||
set aside when its path and size are the cached file's and verify does
|
||||
not credit the path.
|
||||
"""
|
||||
import json # noqa: PLC0415
|
||||
import zipfile # noqa: PLC0415
|
||||
import json
|
||||
import zipfile
|
||||
|
||||
print(f"\n--- {step_title(STEP_LABELS['consistency'])}, destinations ---")
|
||||
try:
|
||||
@@ -542,7 +542,7 @@ def emulator_variants(profiles: list[dict], full: bool) -> list[tuple[str, dict]
|
||||
sampled as check_narrowed_packs samples them unless *full*. A profile
|
||||
without a regional file has nothing --region could withdraw.
|
||||
"""
|
||||
import region as region_mod # noqa: PLC0415
|
||||
import region as region_mod
|
||||
|
||||
regions = sorted({
|
||||
r for profile in profiles for fe in profile.get("files") or []
|
||||
@@ -568,10 +568,10 @@ def check_emulator_packs(
|
||||
required-only rules are written twice, once per side, and only this
|
||||
comparison holds them together. No archive is written and no file read.
|
||||
"""
|
||||
import generate_pack # noqa: PLC0415
|
||||
import packresolve # noqa: PLC0415
|
||||
import verify # noqa: PLC0415
|
||||
from common import ( # noqa: PLC0415
|
||||
import generate_pack
|
||||
import packresolve
|
||||
import verify
|
||||
from common import (
|
||||
ProfileSelectionError,
|
||||
_norm_system_id,
|
||||
build_zip_contents_index,
|
||||
@@ -690,8 +690,8 @@ def narrowed_variants(
|
||||
target, every system, --no-game-data and --required-only. Without
|
||||
*full*, regions, targets and systems are sampled (_matrix_coverage).
|
||||
"""
|
||||
import region as region_mod # noqa: PLC0415
|
||||
from common import list_available_targets # noqa: PLC0415
|
||||
import region as region_mod
|
||||
from common import list_available_targets
|
||||
|
||||
regions = sorted({
|
||||
r for entry in region_mod.platform_region_index(config, profiles).values()
|
||||
@@ -739,10 +739,10 @@ def check_narrowed_packs(
|
||||
compares every value. NARROWINGS_NOT_COMPARED says why --source and
|
||||
--one-per-slot are not compared.
|
||||
"""
|
||||
import generate_pack # noqa: PLC0415
|
||||
import packresolve # noqa: PLC0415
|
||||
import verify # noqa: PLC0415
|
||||
from common import ( # noqa: PLC0415
|
||||
import generate_pack
|
||||
import packresolve
|
||||
import verify
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
group_identical_platforms,
|
||||
list_registered_platforms,
|
||||
@@ -851,9 +851,9 @@ def check_split_packs(
|
||||
RetroBat's 21 openmsx/ twins of openMSX/ files. Offline, as every
|
||||
comparison of this step.
|
||||
"""
|
||||
import generate_pack # noqa: PLC0415
|
||||
import packresolve # noqa: PLC0415
|
||||
from common import ( # noqa: PLC0415
|
||||
import generate_pack
|
||||
import packresolve
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
group_identical_platforms,
|
||||
list_registered_platforms,
|
||||
@@ -993,7 +993,7 @@ def _refuse_offline_export_without_originals(
|
||||
"""
|
||||
if not (args.offline and args.with_export):
|
||||
return
|
||||
from exporter import discover_exporters # noqa: PLC0415
|
||||
from exporter import discover_exporters
|
||||
|
||||
lacking = sorted(
|
||||
name for name, exporter in discover_exporters().items()
|
||||
|
||||
+18
-18
@@ -162,8 +162,8 @@ def entry_hashes(entry: dict) -> list[str]:
|
||||
for source in (entry, *members):
|
||||
if not isinstance(source, dict):
|
||||
continue
|
||||
for field in HASH_FIELDS:
|
||||
for v in parse_hash_list(source.get(field)):
|
||||
for field_name in HASH_FIELDS:
|
||||
for v in parse_hash_list(source.get(field_name)):
|
||||
if v not in tokens:
|
||||
tokens.append(v)
|
||||
return tokens
|
||||
@@ -463,11 +463,11 @@ def collect_citations(document: dict, text: str | None = None) -> list[Citation]
|
||||
if (repo := upstream.parse_repo(url)) is not None
|
||||
)
|
||||
citations: list[Citation] = []
|
||||
for kind, field, holder, key, value in _walk_document(document):
|
||||
for kind, field_name, holder, key, value in _walk_document(document):
|
||||
if kind == "ref":
|
||||
for label, ref in source_ref_values(value):
|
||||
citations.append(Citation(
|
||||
field=field, kind="ref", ref=ref, entry=holder,
|
||||
field=field_name, kind="ref", ref=ref, entry=holder,
|
||||
holder=holder, key=key, label=label,
|
||||
))
|
||||
if isinstance(value, str):
|
||||
@@ -475,7 +475,7 @@ def collect_citations(document: dict, text: str | None = None) -> list[Citation]
|
||||
ref_prose_text(value), known
|
||||
):
|
||||
citations.append(Citation(
|
||||
field=field, kind="prose", ref=run, holder=holder,
|
||||
field=field_name, kind="prose", ref=run, holder=holder,
|
||||
key=key, line=line, path_span=path_span, spans=spans,
|
||||
parts=parts, wrapped=bool(joined_at), joined_at=joined_at,
|
||||
))
|
||||
@@ -484,7 +484,7 @@ def collect_citations(document: dict, text: str | None = None) -> list[Citation]
|
||||
value, known
|
||||
):
|
||||
citations.append(Citation(
|
||||
field=field, kind="prose", ref=run, holder=holder, key=key,
|
||||
field=field_name, kind="prose", ref=run, holder=holder, key=key,
|
||||
line=line, path_span=path_span, spans=spans, parts=parts,
|
||||
wrapped=bool(joined_at), joined_at=joined_at,
|
||||
))
|
||||
@@ -1108,8 +1108,8 @@ def select_repo(profile: dict) -> upstream.Repo | None:
|
||||
A source keyed by build mode with no upstream (uzdoom) names its
|
||||
repositories only in the dict, which a plain string read never parses.
|
||||
"""
|
||||
for field in ("source", "upstream"):
|
||||
repo = upstream.parse_repo(str(profile.get(field) or ""))
|
||||
for field_name in ("source", "upstream"):
|
||||
repo = upstream.parse_repo(str(profile.get(field_name) or ""))
|
||||
if repo is not None:
|
||||
return repo
|
||||
for _, _, url in declared_repositories(profile):
|
||||
@@ -1160,7 +1160,7 @@ def select_views(
|
||||
# A port living on a branch of a fork is absent from the default tip, so
|
||||
# the branch it was read from is followed when the profile names one.
|
||||
declared = str(profile.get("source_branch") or "") or None
|
||||
for field, mode, url in declared_repositories(profile):
|
||||
for field_name, mode, url in declared_repositories(profile):
|
||||
repo = upstream.parse_repo(url)
|
||||
if repo is None or (repo.host, repo.slug) in seen:
|
||||
continue
|
||||
@@ -1168,7 +1168,7 @@ def select_views(
|
||||
# its pin is source_commit. It read `source_mirror_commit`, a field
|
||||
# no profile carries, and fell back to profiled_date, which a bump
|
||||
# never moves (eden judged from f6e76860 while pinned on d16735f5).
|
||||
pin_field = "source" if field == "source_mirror" else field
|
||||
pin_field = "source" if field_name == "source_mirror" else field_name
|
||||
branch = declared if pin_field == "source" else None
|
||||
head = None
|
||||
try:
|
||||
@@ -1206,7 +1206,7 @@ def select_views(
|
||||
if relation and relation[0] == 0 and relation[1] > 0:
|
||||
head = upstream.resolve_head(repo, cache_dir, offline, branch, fresh=True) or head
|
||||
seen.add((repo.host, repo.slug))
|
||||
views.append(RepoView(repo, pin, head, origin, field, mode))
|
||||
views.append(RepoView(repo, pin, head, origin, field_name, mode))
|
||||
if gone and not views:
|
||||
raise upstream.GoneError(f"{profile.get('emulator', '?')}: every declared repository is gone")
|
||||
views = _follow_fork_base(_follow_submodule(views, cache_dir, offline), cache_dir, offline)
|
||||
@@ -1311,12 +1311,12 @@ def declared_repositories(profile: dict) -> list[tuple[str, str, str]]:
|
||||
a declared repository still answers.
|
||||
"""
|
||||
urls: list[tuple[str, str, str]] = []
|
||||
for field in ("source", "upstream", "source_mirror"):
|
||||
value = profile.get(field)
|
||||
for field_name in ("source", "upstream", "source_mirror"):
|
||||
value = profile.get(field_name)
|
||||
if isinstance(value, dict):
|
||||
urls.extend((field, str(k), str(v)) for k, v in value.items() if v)
|
||||
urls.extend((field_name, str(k), str(v)) for k, v in value.items() if v)
|
||||
elif value:
|
||||
urls.append((field, "", str(value)))
|
||||
urls.append((field_name, "", str(value)))
|
||||
return urls
|
||||
|
||||
|
||||
@@ -5520,9 +5520,9 @@ def _refresh_source_paths(args: argparse.Namespace) -> None:
|
||||
"""
|
||||
if not _WRITTEN or args.dry_run or args.offline or os.environ.get("RETROBIOS_OFFLINE"):
|
||||
return
|
||||
import common # noqa: PLC0415
|
||||
import sitesources # noqa: PLC0415
|
||||
from common import write_if_changed # noqa: PLC0415
|
||||
import common
|
||||
import sitesources
|
||||
from common import write_if_changed
|
||||
|
||||
# The run loaded the profiles before writing them, and the loader caches
|
||||
# by directory: read again, the record described the pins just replaced
|
||||
|
||||
@@ -384,7 +384,7 @@ def main() -> int:
|
||||
"(the pipeline writes derivable.json)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["db", "provenance_dir", "emulators_dir", "write_derivable"])
|
||||
if args.write_derivable and not args.derive:
|
||||
@@ -400,7 +400,7 @@ def main() -> int:
|
||||
report = build_report(db, snapshots, archive_members(db), needs=needs)
|
||||
derived: dict[str, dict] = {}
|
||||
if args.derive:
|
||||
from derivations import derivable # noqa: PLC0415
|
||||
from derivations import derivable
|
||||
|
||||
derived = derivable((e for d in report.values() for e in d["missing"]), db)
|
||||
for data in report.values():
|
||||
|
||||
@@ -303,13 +303,12 @@ def _download_and_extract(
|
||||
log.info("downloading %s", source_url)
|
||||
|
||||
req = urllib.request.Request(source_url, headers={"User-Agent": USER_AGENT})
|
||||
with urllib.request.urlopen(req, timeout=DOWNLOAD_TIMEOUT) as resp:
|
||||
with open(tarball_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
with urllib.request.urlopen(req, timeout=DOWNLOAD_TIMEOUT) as resp, open(tarball_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
if measured is not None:
|
||||
measured(tarball_path.stat().st_size)
|
||||
|
||||
@@ -385,13 +384,12 @@ def _download_and_extract_zip(
|
||||
log.info("downloading %s", source_url)
|
||||
|
||||
req = urllib.request.Request(source_url, headers={"User-Agent": USER_AGENT})
|
||||
with urllib.request.urlopen(req, timeout=DOWNLOAD_TIMEOUT) as resp:
|
||||
with open(zip_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
with urllib.request.urlopen(req, timeout=DOWNLOAD_TIMEOUT) as resp, open(zip_path, "wb") as f:
|
||||
while True:
|
||||
chunk = resp.read(65536)
|
||||
if not chunk:
|
||||
break
|
||||
f.write(chunk)
|
||||
if measured is not None:
|
||||
measured(zip_path.stat().st_size)
|
||||
|
||||
@@ -652,7 +650,7 @@ def refresh_all(
|
||||
)
|
||||
if any(results.values()):
|
||||
# A cache the resolver indexed in this process has changed under it.
|
||||
from common import forget_data_dir_index # noqa: PLC0415
|
||||
from common import forget_data_dir_index
|
||||
|
||||
forget_data_dir_index()
|
||||
return results
|
||||
|
||||
@@ -461,7 +461,7 @@ def _github_token_env() -> dict[str, str]:
|
||||
emudeck and retropie target scrapers hit the GitHub API. Without a token
|
||||
the unauthenticated rate limit (60/h) is burnt within a few platforms.
|
||||
"""
|
||||
from common import github_token # noqa: PLC0415
|
||||
from common import github_token
|
||||
|
||||
env = os.environ.copy()
|
||||
token = github_token()
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ def unknown_region_message(raw: str, aliases: dict[str, str], regions: frozenset
|
||||
|
||||
`unknown region: 'uss'` left the user to read the source for `us`.
|
||||
"""
|
||||
import difflib # noqa: PLC0415
|
||||
import difflib
|
||||
|
||||
spelled = raw.strip()
|
||||
close = difflib.get_close_matches(spelled.lower(), [*aliases, *regions], n=3, cutoff=0.5)
|
||||
|
||||
@@ -201,7 +201,7 @@ def main() -> int:
|
||||
)
|
||||
parser.add_argument("--json", action="store_true", help="Machine-readable output")
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["db", "emulators_dir"])
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ if sys.version_info < (3, 9):
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
import yaml # noqa: E402
|
||||
import yaml
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
CONTENT_FILE = ROOT / "tests" / "campaign" / "content.yml"
|
||||
@@ -254,7 +254,7 @@ def content_file(item: dict, content_dir: Path) -> Path:
|
||||
|
||||
def nightly_core(core: str) -> tuple[Path, str]:
|
||||
"""The buildbot nightly of a core, downloaded once, and its URL."""
|
||||
import zipfile # noqa: PLC0415
|
||||
import zipfile
|
||||
|
||||
url = NIGHTLY.format(core=core)
|
||||
target = CORES / f"{core}_libretro.so"
|
||||
@@ -277,7 +277,7 @@ def nightly_core(core: str) -> tuple[Path, str]:
|
||||
def pack_files(emulator: str, region: str, work: Path) -> dict[str, Path]:
|
||||
"""The files generate_pack puts in the emulator's pack for one region,
|
||||
extracted, by their path in the pack."""
|
||||
from ziptools import safe_extract_zip # noqa: PLC0415
|
||||
from ziptools import safe_extract_zip
|
||||
|
||||
out_dir = work / "pack"
|
||||
subprocess.run([sys.executable, str(ROOT / "scripts" / "generate_pack.py"), "--emulator", emulator,
|
||||
@@ -293,7 +293,7 @@ def pack_files(emulator: str, region: str, work: Path) -> dict[str, Path]:
|
||||
|
||||
|
||||
def local_resolver() -> Callable[[dict], Path | None]:
|
||||
from common import load_database, resolve_local_file # noqa: PLC0415
|
||||
from common import load_database, resolve_local_file
|
||||
|
||||
db = load_database(str(ROOT / "database.json"))
|
||||
|
||||
@@ -329,7 +329,7 @@ def probe_when_idle(argv: list[str], max_wait: float,
|
||||
|
||||
|
||||
def run(args: argparse.Namespace) -> int:
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
profile = load_emulator_profiles(str(ROOT / "emulators"))[args.emulator]
|
||||
entries = region_entries(profile, args.system)
|
||||
@@ -373,8 +373,8 @@ def collect(root: Path = ROOT, stored_records: list | None = None) -> list[dict]
|
||||
"""Every region outcome the records under measurements/ hold. A game
|
||||
listed under several systems (sega-megacd and mega-cd) is judged under
|
||||
the one whose profile ran it."""
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from measurement_records import live, read_records # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
from measurement_records import live, read_records
|
||||
|
||||
content: dict[str, list[tuple[str, dict]]] = {}
|
||||
for system, items in load_content(root / "tests" / "campaign" / "content.yml").items():
|
||||
|
||||
@@ -25,7 +25,7 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
from common import run_cli, write_if_changed # noqa: E402
|
||||
from common import run_cli, write_if_changed
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
RETIRED_FILE = REPO_ROOT / "retired.json"
|
||||
|
||||
@@ -210,7 +210,7 @@ class AtomPool:
|
||||
"""Write the digest cache back, when this run learned anything."""
|
||||
if self._digest_cache is None or not self._digests_changed:
|
||||
return
|
||||
from artifacts import write_text_atomic # noqa: PLC0415
|
||||
from artifacts import write_text_atomic
|
||||
|
||||
self._digest_cache.parent.mkdir(parents=True, exist_ok=True)
|
||||
write_text_atomic(
|
||||
@@ -481,7 +481,7 @@ def print_missing(gap: dict) -> None:
|
||||
|
||||
def run_capture(args: argparse.Namespace, db: dict) -> int:
|
||||
"""Write recipes/archives.json for every archive the database lists."""
|
||||
import archive_build # noqa: PLC0415
|
||||
import archive_build
|
||||
|
||||
try:
|
||||
records, failed = archive_build.capture(
|
||||
@@ -512,7 +512,7 @@ def run_capture(args: argparse.Namespace, db: dict) -> int:
|
||||
|
||||
def run_build(args: argparse.Namespace, db: dict) -> int:
|
||||
"""Build one archive, or all of them, from the members the collection holds."""
|
||||
import archive_build # noqa: PLC0415
|
||||
import archive_build
|
||||
|
||||
if not args.output_dir:
|
||||
print("ERROR: --build and --build-all need --output-dir", file=sys.stderr)
|
||||
|
||||
@@ -104,7 +104,7 @@ def configs_root(cg: Configgen) -> dict[str, str]:
|
||||
starts an emulator from (shadPS4's configs/shadps4), with the lines that
|
||||
build it and BIOS.
|
||||
"""
|
||||
import posixpath # noqa: PLC0415
|
||||
import posixpath
|
||||
|
||||
src = cg.source(f"{cg.generators.rsplit('/', 1)[0]}/batoceraPaths.py")
|
||||
if "CONFIGS" not in cg.paths:
|
||||
@@ -1128,9 +1128,9 @@ 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 # noqa: PLC0415
|
||||
from .knulli_launchers import GenericSites, bios_sites
|
||||
except ImportError:
|
||||
from knulli_launchers import GenericSites, bios_sites # type: ignore[no-redef] # noqa: PLC0415
|
||||
from knulli_launchers import GenericSites, bios_sites # type: ignore[no-redef]
|
||||
# A boot disk image the command line names (the Macintosh's
|
||||
# /userdata/bios/<boot_disk>.img) is a file, no search path.
|
||||
return [
|
||||
|
||||
@@ -188,9 +188,7 @@ def _calls(scope: ast.AST, attr: str | None = None, name: str | None = None) ->
|
||||
if not isinstance(node, ast.Call):
|
||||
continue
|
||||
func = node.func
|
||||
if attr is not None and isinstance(func, ast.Attribute) and func.attr == attr:
|
||||
found.append(node)
|
||||
elif name is not None and isinstance(func, ast.Name) and func.id == name:
|
||||
if attr is not None and isinstance(func, ast.Attribute) and func.attr == attr or name is not None and isinstance(func, ast.Name) and func.id == name:
|
||||
found.append(node)
|
||||
return sorted(found, key=lambda call: (call.lineno, call.col_offset))
|
||||
|
||||
|
||||
@@ -335,9 +335,7 @@ def main() -> None:
|
||||
found = 0
|
||||
missing = []
|
||||
for r in reqs:
|
||||
if r.name in db["indexes"]["by_name"]:
|
||||
found += 1
|
||||
elif r.md5 and r.md5 in db["indexes"]["by_md5"]:
|
||||
if r.name in db["indexes"]["by_name"] or r.md5 and r.md5 in db["indexes"]["by_md5"]:
|
||||
found += 1
|
||||
else:
|
||||
missing.append(r)
|
||||
|
||||
@@ -335,19 +335,19 @@ class Scraper(BaseScraper):
|
||||
bios_col = ""
|
||||
for key in row:
|
||||
if key and "bios" in key.lower():
|
||||
bios_col = self._clean_markdown((row[key] or ""))
|
||||
bios_col = self._clean_markdown(row[key] or "")
|
||||
break
|
||||
if not bios_col or bios_col.lower() in ("not required", ""):
|
||||
continue
|
||||
folder_col = ""
|
||||
for key in row:
|
||||
if key and "folder" in key.lower():
|
||||
folder_col = self._clean_markdown((row[key] or ""))
|
||||
folder_col = self._clean_markdown(row[key] or "")
|
||||
break
|
||||
system_col = ""
|
||||
for key in row:
|
||||
if key and "system" in key.lower():
|
||||
system_col = self._clean_markdown((row[key] or ""))
|
||||
system_col = self._clean_markdown(row[key] or "")
|
||||
break
|
||||
slug = None
|
||||
for part in re.split(r"[`\s/]+", folder_col):
|
||||
|
||||
@@ -26,7 +26,6 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import io
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
@@ -94,9 +94,9 @@ class Scraper(BaseScraper):
|
||||
|
||||
def submodule_revision(self) -> str:
|
||||
"""The batocera.linux commit KNULLI's batocera submodule pins at the tag."""
|
||||
import json # noqa: PLC0415
|
||||
import json
|
||||
|
||||
from .base_scraper import github_headers # noqa: PLC0415
|
||||
from .base_scraper import github_headers
|
||||
|
||||
url = _SUBMODULE.format(path=BATOCERA_SUBMODULE, ref=self.tag)
|
||||
req = urllib.request.Request(url, headers=github_headers())
|
||||
|
||||
@@ -572,7 +572,7 @@ def hatari_libretro(sources: dict[str, Source]) -> list[Record]:
|
||||
guard = src.find(r'if \(core != "hatarib"\)', "hatarib guard")
|
||||
method = src.enclosing(guard.start())
|
||||
tos_img = src.find(
|
||||
rf'string (\w+) = Path\.Combine\((\w+), "([^"]+)"\);', "hatarib tos.img path",
|
||||
r'string (\w+) = Path\.Combine\((\w+), "([^"]+)"\);', "hatarib tos.img path",
|
||||
method[0], method[1],
|
||||
)
|
||||
own = src.find(
|
||||
|
||||
@@ -310,7 +310,7 @@ class Scraper(BaseScraper):
|
||||
|
||||
def _fetch_remote_manifests(self) -> list[tuple[str, dict]]:
|
||||
"""Fetch component manifests via GitHub API."""
|
||||
from common import github_token # noqa: PLC0415
|
||||
from common import github_token
|
||||
|
||||
token = github_token()
|
||||
headers = {"User-Agent": "retrobios-scraper/1.0"}
|
||||
|
||||
@@ -483,7 +483,7 @@ LIST_SEPARATORS = {"advmame": ":", "advmame-0.94": ":", "advmame-1.4": ":"}
|
||||
DEFAULT_LIST_SEPARATOR = ";"
|
||||
|
||||
|
||||
def _search_list_in_roms(event: "Event", separator: str = DEFAULT_LIST_SEPARATOR) -> bool:
|
||||
def _search_list_in_roms(event: Event, separator: str = DEFAULT_LIST_SEPARATOR) -> bool:
|
||||
"""An iniSet whose value is a list of folders below the roms root.
|
||||
|
||||
One folder alone is where a program writes (cfg_directory, nvram_directory
|
||||
|
||||
@@ -14,8 +14,8 @@ from pathlib import Path
|
||||
import yaml
|
||||
|
||||
from . import Fetcher, SourceError, load_sources, scrape_setup
|
||||
from upstream import UpstreamError # noqa: E402 (the package puts scripts/ on sys.path)
|
||||
from artifacts import write_text_atomic # noqa: E402
|
||||
from upstream import UpstreamError
|
||||
from artifacts import write_text_atomic
|
||||
from ..base_scraper import _PlatformDumper
|
||||
|
||||
DEFAULT_DIR = Path("platforms") / "romfolders"
|
||||
|
||||
@@ -57,8 +57,8 @@ class BaseTargetScraper(ABC):
|
||||
"""Write target data to YAML file."""
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
raise ImportError("PyYAML required: pip install pyyaml")
|
||||
except ImportError as exc:
|
||||
raise ImportError("PyYAML required: pip install pyyaml") from exc
|
||||
from common import write_text_atomic
|
||||
|
||||
write_text_atomic(
|
||||
|
||||
@@ -68,7 +68,7 @@ _MODULE_FLAGS_RE = re.compile(r'rp_module_flags\s*=\s*["\']([^"\']*)["\']')
|
||||
|
||||
def _fetch(url: str, accept: str = "text/plain") -> str:
|
||||
headers = {"User-Agent": "retrobios-scraper/1.0", "Accept": accept}
|
||||
from common import github_token # noqa: PLC0415
|
||||
from common import github_token
|
||||
|
||||
token = github_token()
|
||||
if token and "api.github.com" in url:
|
||||
|
||||
@@ -214,7 +214,7 @@ class Scraper(BaseTargetScraper):
|
||||
return fetch_bytes(f"{RAW_BASE.format(tag=self.tag)}/{path}").decode("utf-8")
|
||||
|
||||
def _devices(self) -> list[str]:
|
||||
import json # noqa: PLC0415
|
||||
import json
|
||||
|
||||
listing = json.loads(fetch_bytes(
|
||||
f"{GITHUB_API}/{DEVICES_DIR}?ref={self.tag}", headers=github_headers()
|
||||
|
||||
@@ -226,7 +226,7 @@ def ecdsa_verify_sha256(
|
||||
h = hashlib.sha256(message).digest()
|
||||
e = int.from_bytes(h, "big")
|
||||
# Truncate to bit length of n
|
||||
if 256 > _N_BITLEN:
|
||||
if _N_BITLEN < 256:
|
||||
e >>= 256 - _N_BITLEN
|
||||
|
||||
# w = s^(-1) mod n
|
||||
|
||||
@@ -37,7 +37,7 @@ from html.parser import HTMLParser
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import run_cli # noqa: E402
|
||||
from common import run_cli
|
||||
|
||||
SITE = "https://abdess.github.io"
|
||||
BASE = "/retrobios/"
|
||||
|
||||
@@ -13,8 +13,8 @@ import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
import siteinputs # noqa: E402
|
||||
from common import GAME_DATA_TOPS, load_emulator_profiles # noqa: E402
|
||||
import siteinputs
|
||||
from common import GAME_DATA_TOPS, load_emulator_profiles
|
||||
|
||||
|
||||
def _copy_places(db: dict) -> dict[str, set[tuple[str, str, str]]]:
|
||||
@@ -94,7 +94,7 @@ def _engine_sections(manufacturers: dict[str, dict[str, list]]) -> dict[str, dic
|
||||
top joins that top, and a folder named by a profile key is headed with
|
||||
the engine's name (SECTION_LABELS), its address unchanged.
|
||||
"""
|
||||
from siterender import _PROGRAM_TOPS, SECTION_LABELS, record_card_move # noqa: PLC0415
|
||||
from siterender import _PROGRAM_TOPS, SECTION_LABELS, record_card_move
|
||||
|
||||
profiles = {key: profile for key, profile in _profiles_on_disk().items()
|
||||
if profile.get("type") != "alias" and profile.get("role") != "test"}
|
||||
@@ -164,6 +164,6 @@ def _profiles_on_disk() -> dict[str, dict]:
|
||||
return _profiles_in(str(siteinputs.current().emulators), skip_aliases=False)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _profiles_in(emulators_dir: str, skip_aliases: bool) -> dict[str, dict]:
|
||||
return load_emulator_profiles(emulators_dir, skip_aliases=skip_aliases)
|
||||
@@ -35,7 +35,7 @@ import urllib.parse
|
||||
from collections import Counter
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from functools import lru_cache
|
||||
from functools import cache
|
||||
from pathlib import Path
|
||||
from xml.sax.saxutils import escape
|
||||
|
||||
@@ -415,7 +415,7 @@ def registry() -> dict:
|
||||
return _registry_in(str(siteinputs.current().platforms))
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def _registry_in(platforms_dir: str) -> dict:
|
||||
import yaml
|
||||
|
||||
@@ -429,7 +429,7 @@ def setups() -> tuple[str, ...]:
|
||||
return _setups_in(str(siteinputs.current().platforms))
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def _setups_in(platforms_dir: str) -> tuple[str, ...]:
|
||||
from common import list_registered_platforms
|
||||
|
||||
@@ -449,7 +449,7 @@ def platform_modes() -> dict[str, tuple[str, str, str | None]]:
|
||||
return _platform_modes_in(str(siteinputs.current().platforms))
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def _platform_modes_in(platforms_dir: str) -> dict[str, tuple[str, str, str | None]]:
|
||||
from common import load_platform_config
|
||||
|
||||
@@ -478,7 +478,7 @@ def emulator_names() -> dict[str, str]:
|
||||
return _emulator_names_in(str(siteinputs.current().emulators))
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def _emulator_names_in(emulators_dir: str) -> dict[str, str]:
|
||||
import yaml
|
||||
|
||||
@@ -562,7 +562,7 @@ def _mode_summary() -> str:
|
||||
MINUI_EXAMPLES = (("Sony PlayStation", "PS"), ("Game Boy Advance", "GBA"), ("Sega Genesis", "MD"))
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def minui_files() -> dict[str, list[str]]:
|
||||
manifest = json.loads((ROOT / "install" / "minui.json").read_text(encoding="utf-8"))
|
||||
by_tag: dict[str, list[str]] = {}
|
||||
@@ -747,7 +747,7 @@ def _figures() -> dict[str, Figure]:
|
||||
}
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def figures() -> dict[str, Figure]:
|
||||
return _figures()
|
||||
|
||||
@@ -818,7 +818,7 @@ IMAGE_LINK = re.compile(r"(!\[[^\]\n]*\]\()(https?://[^)\s]+)(\))")
|
||||
IMG_SRC = re.compile(r'(<img\b[^>]*?\bsrc=")(https?://[^"]+)(")')
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def local_images() -> dict[str, str]:
|
||||
"""Remote URL -> path under the site root, from the two source manifests."""
|
||||
mapping: dict[str, str] = {}
|
||||
@@ -928,7 +928,7 @@ def _string(node: ast.expr, constants: dict[str, str]) -> str:
|
||||
raise ValueError(f"install.py: an option help that is not a string: {ast.unparse(node)}")
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
@cache
|
||||
def installer_options() -> tuple[tuple[str, str], ...]:
|
||||
"""(usage, help) for each option of install.py, in the order --help lists them."""
|
||||
tree = ast.parse((ROOT / "install.py").read_text(encoding="utf-8"))
|
||||
|
||||
@@ -137,7 +137,7 @@ def opened(record: dict) -> str | None:
|
||||
def load_observations(path: Path) -> dict[str, dict]:
|
||||
"""Each record id or subject an observation covers, with its issue
|
||||
number and words."""
|
||||
import yaml # noqa: PLC0415
|
||||
import yaml
|
||||
|
||||
if not path.is_file():
|
||||
return {}
|
||||
@@ -430,7 +430,7 @@ class Built:
|
||||
|
||||
|
||||
def load_profiles(emulators_dir: Path) -> dict:
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
return load_emulator_profiles(str(emulators_dir), skip_aliases=False)
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ def tree_key(repo: upstream.Repo, pin: str) -> str:
|
||||
return f"{repo.host}/{repo.slug}@{pin}"
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _verified() -> dict[str, frozenset[str]]:
|
||||
"""The committed record, empty when it has not been written."""
|
||||
try:
|
||||
@@ -183,7 +183,7 @@ def _verified() -> dict[str, frozenset[str]]:
|
||||
return {key: frozenset(paths) for key, paths in data.items()}
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _tree_paths(repo: upstream.Repo, pin: str) -> frozenset[str]:
|
||||
"""The cited paths of a repository at a revision that its tree holds."""
|
||||
return _verified().get(tree_key(repo, pin), frozenset())
|
||||
@@ -767,7 +767,7 @@ def main() -> int:
|
||||
if not args.fetch and not any(path.is_dir() for path in cache_dirs):
|
||||
print(f"Error: no tree cache at {', '.join(map(str, cache_dirs))}", file=sys.stderr)
|
||||
return 1
|
||||
from common import ( # noqa: PLC0415
|
||||
from common import (
|
||||
load_emulator_profiles,
|
||||
repository_output_lock,
|
||||
write_if_changed,
|
||||
|
||||
@@ -265,7 +265,7 @@ def steps_figure(tab: str) -> list[str]:
|
||||
|
||||
def tab_demo(tab: str) -> list[str]:
|
||||
"""The recording a tab shows, as generate_site writes the component."""
|
||||
from generate_site import install_demo # noqa: PLC0415
|
||||
from generate_site import install_demo
|
||||
|
||||
variant = demo_variant(tab)
|
||||
return install_demo(variant, tab) if variant else []
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ def platform_slot_claims(
|
||||
config: dict, profiles: dict, target_cores: set[str] | None = None
|
||||
) -> dict[str, dict[str, dict]]:
|
||||
"""What each emulator a platform runs declares at each key, unmerged."""
|
||||
from common import resolve_platform_cores # noqa: PLC0415
|
||||
from common import resolve_platform_cores
|
||||
|
||||
cores = resolve_platform_cores(config, profiles, target_cores=target_cores)
|
||||
return slot_claims({n: profiles[n] for n in cores if n in profiles})
|
||||
|
||||
+8
-8
@@ -201,7 +201,7 @@ def profile_claims(
|
||||
standalone_cores = standalone_cores or set()
|
||||
placement = None
|
||||
if config is not None:
|
||||
from packextras import ExtraPlacement # noqa: PLC0415
|
||||
from packextras import ExtraPlacement
|
||||
|
||||
placement = ExtraPlacement(config, base_dest, profiles)
|
||||
claims: list[Claim] = []
|
||||
@@ -212,14 +212,14 @@ def profile_claims(
|
||||
# carries its scan candidates, never its named entries.
|
||||
if profile.get("bios_mode") == "agnostic":
|
||||
continue
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_cores):
|
||||
for layout, is_standalone in platform_layouts(emu_name, profile, standalone_cores):
|
||||
claims.extend(
|
||||
_archive_claims(
|
||||
emu_name, profile, is_standalone, db, base_dest, placement,
|
||||
emu_name, layout, is_standalone, db, base_dest, placement,
|
||||
zip_contents, data_dir_registry,
|
||||
)
|
||||
)
|
||||
for entry in profile.get("files") or []:
|
||||
for entry in layout.get("files") or []:
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
# The same rule as the gap report and the builder: an entry the
|
||||
@@ -249,7 +249,7 @@ def profile_claims(
|
||||
{
|
||||
"profile": emu_name,
|
||||
"system": entry.get("system"),
|
||||
"systems": entry_system_ids(entry, profile),
|
||||
"systems": entry_system_ids(entry, layout),
|
||||
},
|
||||
dest,
|
||||
)
|
||||
@@ -259,7 +259,7 @@ def profile_claims(
|
||||
# The owner's own copy is the one the builder ships.
|
||||
local, status = resolve_local_file(
|
||||
{
|
||||
**with_archive_members(entry, profile.get("files") or []),
|
||||
**with_archive_members(entry, layout.get("files") or []),
|
||||
"source_profile": emu_name,
|
||||
},
|
||||
db,
|
||||
@@ -269,7 +269,7 @@ def profile_claims(
|
||||
)
|
||||
if status == "name_exact" and _size_the_code_reads(entry, local):
|
||||
status = SIZE_EXACT
|
||||
accepts = tuple(content_alternatives(entry, profile))
|
||||
accepts = tuple(content_alternatives(entry, layout))
|
||||
claims.append(
|
||||
Claim(
|
||||
origin="profile",
|
||||
@@ -1038,7 +1038,7 @@ def main() -> int:
|
||||
"without it the run reports them and exits 0",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from common import work_from_repo_root # noqa: PLC0415
|
||||
from common import work_from_repo_root
|
||||
|
||||
work_from_repo_root(args, parser, ["db", "platforms_dir", "emulators_dir"])
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ def parse_xwd(data: bytes) -> tuple[int, int, bytes]:
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
def github_releases(repo: str) -> list[dict]:
|
||||
from scraper.base_scraper import github_headers # noqa: PLC0415
|
||||
from scraper.base_scraper import github_headers
|
||||
|
||||
request = urllib.request.Request(f"https://api.github.com/repos/{repo}/releases",
|
||||
headers=github_headers())
|
||||
|
||||
+2
-2
@@ -230,7 +230,7 @@ def _headers(url: str, accept_json: bool = False) -> dict[str, str]:
|
||||
if accept_json:
|
||||
headers["Accept"] = "application/json"
|
||||
if urllib.parse.urlsplit(url).netloc in GITHUB_HOSTS:
|
||||
from common import github_token # noqa: PLC0415
|
||||
from common import github_token
|
||||
|
||||
# GITHUB_TOKEN, else the one gh is logged in with.
|
||||
token = github_token()
|
||||
@@ -667,7 +667,7 @@ def _github_graphql(
|
||||
GraphQL refuses anonymous calls, so an untokened run keeps the REST
|
||||
answer it already had.
|
||||
"""
|
||||
from common import github_token # noqa: PLC0415
|
||||
from common import github_token
|
||||
|
||||
body = json.dumps({"query": query, "variables": variables}, sort_keys=True)
|
||||
target = Path(cache_dir) / "_api" / f"{hashlib.sha256(body.encode()).hexdigest()}.json"
|
||||
|
||||
@@ -116,7 +116,7 @@ def _config_records_without_evidence(path: Path, document: object) -> list[str]:
|
||||
"""
|
||||
if not isinstance(document, dict):
|
||||
return []
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref # noqa: PLC0415
|
||||
from scraper.shell_launchers import config_ref, is_feature_ref
|
||||
|
||||
out: list[str] = []
|
||||
for index, record in enumerate(document.get("launchers") or []):
|
||||
@@ -213,9 +213,7 @@ def _group_requirement_split(path: Path, document: object) -> list[str]:
|
||||
|
||||
|
||||
_CODE_SUFFIXES = frozenset(
|
||||
"c cc cpp cxx c++ h hh hpp hxx inc inl ipp m mm mjs cjs js jsx ts tsx py cs java kt "
|
||||
"go rs lua pas pp asm s sh bash zsh ps1 bat cmd vbs swift d zig nim qml qc rb pl php "
|
||||
"scala ml hs dart vue ino z80 smali".split()
|
||||
["c", "cc", "cpp", "cxx", "c++", "h", "hh", "hpp", "hxx", "inc", "inl", "ipp", "m", "mm", "mjs", "cjs", "js", "jsx", "ts", "tsx", "py", "cs", "java", "kt", "go", "rs", "lua", "pas", "pp", "asm", "s", "sh", "bash", "zsh", "ps1", "bat", "cmd", "vbs", "swift", "d", "zig", "nim", "qml", "qc", "rb", "pl", "php", "scala", "ml", "hs", "dart", "vue", "ino", "z80", "smali"]
|
||||
)
|
||||
_CODE_FILE = re.compile(r"(?<=[\w+-])\.([A-Za-z0-9+]+)\b")
|
||||
# A compiled image: a part that names one has to say where in it the file
|
||||
@@ -788,7 +786,7 @@ def _semantic_standalone_checks(path: Path, layouts: object) -> list[str]:
|
||||
|
||||
def _event_schema_errors() -> list[str]:
|
||||
"""install-events.schema.json is EVENT_KEYS written out, and a valid schema."""
|
||||
import generate_event_schema # noqa: PLC0415
|
||||
import generate_event_schema
|
||||
|
||||
path = ROOT / "schemas" / generate_event_schema.OUTPUT.name
|
||||
label = path.relative_to(ROOT).as_posix()
|
||||
@@ -828,7 +826,7 @@ def _format_errors() -> list[str]:
|
||||
def _measurement_errors(root: Path | None = None) -> list[str]:
|
||||
"""Every record line under measurements/, against its schema and the
|
||||
rules measurement_records.read_records applies."""
|
||||
import measurement_records as mr # noqa: PLC0415
|
||||
import measurement_records as mr
|
||||
|
||||
root = root or ROOT
|
||||
validator = _validator("core-probe-record.schema.json")
|
||||
|
||||
@@ -403,9 +403,9 @@ def _check_get_pages(
|
||||
recorded tag, and one without links none and gives the command.
|
||||
"""
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import release_record # noqa: PLC0415
|
||||
from siteguides import INSTALL_SH # noqa: PLC0415
|
||||
from common import list_registered_platforms, list_release_pack_platforms # noqa: PLC0415
|
||||
import release_record
|
||||
from siteguides import INSTALL_SH
|
||||
from common import list_registered_platforms, list_release_pack_platforms
|
||||
|
||||
if not (platforms_dir / "_registry.yml").is_file():
|
||||
return [f"no platform registry in {platforms_dir}"]
|
||||
@@ -499,7 +499,7 @@ def main() -> None:
|
||||
help="stop listing after this many errors (default: %(default)s)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
from common import require_directory # noqa: PLC0415
|
||||
from common import require_directory
|
||||
|
||||
require_directory(str(args.platforms_dir), "--platforms-dir")
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ from common import (
|
||||
name_match_size_ok,
|
||||
sanitize_pack_path,
|
||||
shape_fits,
|
||||
size_fits,
|
||||
)
|
||||
from hashing import md5_composite, parse_hash_list, parse_md5_list
|
||||
from nativemode import SIZE_AND_ANY_HASH, digest_algorithm, hash_mismatch_excludes_file
|
||||
|
||||
+14
-14
@@ -572,10 +572,10 @@ def find_undeclared_files(
|
||||
# (ARMSX2's arcade/proverb.zip once ROCKNIX binds bios/armsx2).
|
||||
agnostic = profile.get("bios_mode") == "agnostic"
|
||||
|
||||
for profile, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
for layout, is_standalone in platform_layouts(emu_name, profile, standalone_set):
|
||||
|
||||
for f in expand_directory_entries(
|
||||
profile.get("files", []), db, is_standalone
|
||||
layout.get("files", []), db, is_standalone
|
||||
):
|
||||
if agnostic and not f.get("unplaced"):
|
||||
continue
|
||||
@@ -613,7 +613,7 @@ def find_undeclared_files(
|
||||
# Below the save directory each core is handed a folder
|
||||
# of its own: two cores reading hiscore.dat there read
|
||||
# two files.
|
||||
("save", core_save_folder(profile)) if save_root
|
||||
("save", core_save_folder(layout)) if save_root
|
||||
else (f["root"],) if f.get("root") in OUTER_ROOTS
|
||||
# In the emulator's own folder: no other core reads it.
|
||||
else ("emulator", emu_name) if f.get("unplaced") else None,
|
||||
@@ -662,8 +662,8 @@ def find_undeclared_files(
|
||||
)
|
||||
archive_entries[archive_key] = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": entry_system_ids(f, profile),
|
||||
"emulator": layout.get("emulator", emu_name),
|
||||
"systems": entry_system_ids(f, layout),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"selection_slot": f.get("selection_slot"),
|
||||
@@ -680,14 +680,14 @@ def find_undeclared_files(
|
||||
"expected": {},
|
||||
"archive_file_count": 0,
|
||||
"archive_required_count": 0,
|
||||
"members": archive_members(archive, profile.get("files", [])),
|
||||
"members": archive_members(archive, layout.get("files", [])),
|
||||
}
|
||||
if f.get("system_dir"):
|
||||
archive_entries[archive_key]["system_dir"] = f["system_dir"]
|
||||
# The archive's own declaration names its sets: an
|
||||
# archive is a member like a loose file.
|
||||
own = archive_entry(archive, profile.get("files", []))
|
||||
archive_entries[archive_key].update(set_fields(own, profile))
|
||||
own = archive_entry(archive, layout.get("files", []))
|
||||
archive_entries[archive_key].update(set_fields(own, layout))
|
||||
set_records.append((
|
||||
set_keys((emu_name, is_standalone), own), own, in_repo,
|
||||
(archive_entries[archive_key], None),
|
||||
@@ -761,15 +761,15 @@ def find_undeclared_files(
|
||||
# ROM is not Basilisk II's ROM.
|
||||
_lp, _st = resolve_local_file(owned, db, dest_hint=dest)
|
||||
if core_size_refusal(
|
||||
f, _lp, same_slot_entries(profile.get("files"), fname, dest)
|
||||
f, _lp, same_slot_entries(layout.get("files"), fname, dest)
|
||||
):
|
||||
in_repo = False
|
||||
|
||||
checks = _parse_validation(f.get("validation"))
|
||||
entry = {
|
||||
"profile": emu_name,
|
||||
"emulator": profile.get("emulator", emu_name),
|
||||
"systems": entry_system_ids(f, profile),
|
||||
"emulator": layout.get("emulator", emu_name),
|
||||
"systems": entry_system_ids(f, layout),
|
||||
"system": f.get("system"),
|
||||
"region": f.get("region"),
|
||||
"selection_slot": f.get("selection_slot"),
|
||||
@@ -782,7 +782,7 @@ def find_undeclared_files(
|
||||
"in_repo": in_repo,
|
||||
"note": f.get("note", ""),
|
||||
"checks": sorted(checks) if checks else [],
|
||||
**set_fields(f, profile),
|
||||
**set_fields(f, layout),
|
||||
"source_ref": f.get("source_ref"),
|
||||
"expected": _build_expected(f, checks),
|
||||
**_identity_of(f),
|
||||
@@ -793,12 +793,12 @@ def find_undeclared_files(
|
||||
entry["contents"] = f["contents"]
|
||||
if save_root:
|
||||
entry["root"] = "save"
|
||||
folder = core_save_folder(profile)
|
||||
folder = core_save_folder(layout)
|
||||
if folder is not None:
|
||||
entry["core_folder"] = folder
|
||||
elif f.get("system_dir"):
|
||||
entry["system_dir"] = f["system_dir"]
|
||||
members = with_archive_members(f, profile.get("files", [])).get("members")
|
||||
members = with_archive_members(f, layout.get("files", [])).get("members")
|
||||
if members:
|
||||
entry["members"] = members
|
||||
if f.get("layout_path"):
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ MAX_HASHED_MEMBER = 512 * 1024 * 1024
|
||||
|
||||
|
||||
def _read_member_cache(path: str) -> dict[str, list[list]]:
|
||||
import json # noqa: PLC0415
|
||||
import json
|
||||
|
||||
try:
|
||||
with open(path, encoding="utf-8") as fh:
|
||||
@@ -135,7 +135,7 @@ def _read_member_cache(path: str) -> dict[str, list[list]]:
|
||||
|
||||
|
||||
def _write_member_cache(path: str, data: dict[str, list[list]]) -> None:
|
||||
import json # noqa: PLC0415
|
||||
import json
|
||||
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
fd, scratch = tempfile.mkstemp(dir=os.path.dirname(path), suffix=".tmp")
|
||||
|
||||
@@ -119,7 +119,7 @@ class TheTwoRomsFormAPairTheCodeTakes(unittest.TestCase):
|
||||
|
||||
class DolphinGetsAPairItTakes(unittest.TestCase):
|
||||
def test_each_dolphin_dsp_rom_resolves_to_an_accepted_dump(self):
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not database.exists():
|
||||
@@ -139,7 +139,7 @@ class DolphinGetsAPairItTakes(unittest.TestCase):
|
||||
|
||||
|
||||
def test_every_paired_profile_resolves_a_pair_its_code_takes(self):
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
from common import load_emulator_profiles
|
||||
|
||||
database = REPO_ROOT / "database.json"
|
||||
if not database.exists():
|
||||
|
||||
@@ -70,9 +70,9 @@ class OneWinnerRuleForEveryReader(unittest.TestCase):
|
||||
won in the report and lost in the pack. The rule takes no registry."""
|
||||
|
||||
def test_the_rule_reads_no_data_directory(self):
|
||||
import inspect # noqa: PLC0415
|
||||
import inspect
|
||||
|
||||
import generate_pack # noqa: PLC0415
|
||||
import generate_pack
|
||||
|
||||
parameters = inspect.signature(generate_pack._preferred_entries).parameters
|
||||
self.assertFalse([name for name in parameters if "registry" in name])
|
||||
|
||||
@@ -90,14 +90,14 @@ class HeldArchivesMatchTheirRecipes(unittest.TestCase):
|
||||
bios = REPO_ROOT / "bios"
|
||||
if not bios.is_dir() or not (REPO_ROOT / "recipes").is_dir():
|
||||
self.skipTest("bios/ or recipes/ is not present")
|
||||
from common import ( # noqa: PLC0415
|
||||
from common import (
|
||||
list_registered_platforms,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
variant_base_name,
|
||||
)
|
||||
from hashing import md5_composite_of # noqa: PLC0415
|
||||
from romset_recipes import load_dat_recipes # noqa: PLC0415
|
||||
from hashing import md5_composite_of
|
||||
from romset_recipes import load_dat_recipes
|
||||
|
||||
allowed: dict[str, set[str]] = defaultdict(set)
|
||||
for archive, per_label in load_dat_recipes(REPO_ROOT / "recipes").items():
|
||||
|
||||
+17
-25
@@ -50,32 +50,27 @@ class ArtifactLockTest(unittest.TestCase):
|
||||
self.dir = _tempdir(self)
|
||||
|
||||
def test_writer_excludes_writer(self):
|
||||
with artifact_lock(self.dir):
|
||||
with self.assertRaises(ArtifactLockBusy):
|
||||
with artifact_lock(self.dir):
|
||||
pass
|
||||
with artifact_lock(self.dir), self.assertRaises(ArtifactLockBusy), artifact_lock(self.dir):
|
||||
pass
|
||||
|
||||
def test_writer_excludes_reader(self):
|
||||
with artifact_lock(self.dir):
|
||||
with self.assertRaises(ArtifactLockBusy):
|
||||
with artifact_lock(self.dir, exclusive=False):
|
||||
pass
|
||||
|
||||
def test_readers_share(self):
|
||||
with artifact_lock(self.dir, exclusive=False):
|
||||
with artifact_lock(self.dir), self.assertRaises(ArtifactLockBusy):
|
||||
with artifact_lock(self.dir, exclusive=False):
|
||||
pass
|
||||
|
||||
def test_readers_share(self):
|
||||
with artifact_lock(self.dir, exclusive=False), artifact_lock(self.dir, exclusive=False):
|
||||
pass
|
||||
|
||||
def test_a_reader_never_creates_the_directory(self):
|
||||
"""A mistyped --output-dir given to --verify-packs or release_record
|
||||
was created holding a .lock, and the next run with the same typo no
|
||||
longer said the path did not exist."""
|
||||
from common import ArtifactDirectoryMissing # noqa: PLC0415
|
||||
from common import ArtifactDirectoryMissing
|
||||
|
||||
missing = os.path.join(self.dir, "sub", "dsit")
|
||||
with self.assertRaises(ArtifactDirectoryMissing):
|
||||
with artifact_lock(missing, exclusive=False):
|
||||
pass
|
||||
with self.assertRaises(ArtifactDirectoryMissing), artifact_lock(missing, exclusive=False):
|
||||
pass
|
||||
self.assertFalse(os.path.exists(os.path.join(self.dir, "sub")))
|
||||
|
||||
def test_split_refuses_a_missing_target_before_locking(self):
|
||||
@@ -95,17 +90,15 @@ class ArtifactLockTest(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def test_lock_is_released_on_error(self):
|
||||
with self.assertRaises(ValueError):
|
||||
with artifact_lock(self.dir):
|
||||
raise ValueError("boom")
|
||||
with self.assertRaises(ValueError), artifact_lock(self.dir):
|
||||
raise ValueError("boom")
|
||||
with artifact_lock(self.dir):
|
||||
pass
|
||||
|
||||
def test_separate_directories_do_not_contend(self):
|
||||
other = _tempdir(self)
|
||||
with artifact_lock(self.dir):
|
||||
with artifact_lock(other):
|
||||
pass
|
||||
with artifact_lock(self.dir), artifact_lock(other):
|
||||
pass
|
||||
|
||||
def test_lock_survives_a_missing_directory(self):
|
||||
missing = os.path.join(self.dir, "not-created-yet")
|
||||
@@ -149,7 +142,7 @@ class PackLockCliTest(unittest.TestCase):
|
||||
"""The refresh waits for every run holding a data tree, and a
|
||||
pipeline holds them all for its whole run: probed after the refresh,
|
||||
a second build sat silent for hours instead of being refused."""
|
||||
from refresh_data_dirs import cache_lock # noqa: PLC0415
|
||||
from refresh_data_dirs import cache_lock
|
||||
|
||||
platforms = Path(self.dir) / "platforms"
|
||||
platforms.mkdir()
|
||||
@@ -254,9 +247,8 @@ class PipelineHoldsItsFixedOutputs(unittest.TestCase):
|
||||
|
||||
def test_two_holds_of_the_repository_exclude_each_other(self):
|
||||
with hold_repository_outputs(str(REPO_ROOT)), \
|
||||
self.assertRaises(ArtifactLockBusy):
|
||||
with hold_repository_outputs(str(REPO_ROOT)):
|
||||
pass
|
||||
self.assertRaises(ArtifactLockBusy), hold_repository_outputs(str(REPO_ROOT)):
|
||||
pass
|
||||
|
||||
|
||||
class TheSuiteTakesTheRepositoryHoldInItsScratch(unittest.TestCase):
|
||||
|
||||
@@ -180,7 +180,7 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
|
||||
def test_threads_reading_the_mode_leave_the_umask_alone(self):
|
||||
"""mame_devices fetches on eight threads and every cache write reads
|
||||
the umask: unguarded, two readers interleaved and left it at 0."""
|
||||
import threading # noqa: PLC0415
|
||||
import threading
|
||||
|
||||
interval = sys.getswitchinterval()
|
||||
sys.setswitchinterval(1e-6)
|
||||
@@ -210,9 +210,9 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
|
||||
self.assertEqual(offenders, [])
|
||||
|
||||
def test_packs_and_their_manifest(self):
|
||||
import zipfile # noqa: PLC0415
|
||||
import zipfile
|
||||
|
||||
import generate_pack # noqa: PLC0415
|
||||
import generate_pack
|
||||
|
||||
pack = self.dir / "Pack.zip"
|
||||
with generate_pack._writing_pack(str(pack)) as zf:
|
||||
@@ -230,7 +230,7 @@ class ScratchFilesGetThePlainMode(unittest.TestCase):
|
||||
copy_file_atomic is the one exception: copy2 gives the scratch the
|
||||
source file's own mode.
|
||||
"""
|
||||
import ast # noqa: PLC0415
|
||||
import ast
|
||||
|
||||
def name_of(node: ast.AST) -> str | None:
|
||||
return node.id if isinstance(node, ast.Name) else None
|
||||
@@ -317,8 +317,8 @@ class ATerminatedBuildLeavesNoScratch(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_sigterm_removes_the_partial_pack(self):
|
||||
import signal # noqa: PLC0415
|
||||
import subprocess # noqa: PLC0415
|
||||
import signal
|
||||
import subprocess
|
||||
|
||||
if not hasattr(signal, "SIGTERM") or os.name != "posix":
|
||||
self.skipTest("POSIX signals")
|
||||
|
||||
@@ -104,7 +104,7 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_an_older_interpreter_is_refused_before_the_first_step(self):
|
||||
import shutil # noqa: PLC0415
|
||||
import shutil
|
||||
|
||||
python38 = shutil.which("python3.8")
|
||||
if python38 is None:
|
||||
@@ -123,7 +123,7 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
def test_the_readme_build_command_names_the_floor(self):
|
||||
"""The README's first command is generate_pack.py. Under 3.8 it
|
||||
stopped on a raw SyntaxError at a parenthesized `with`."""
|
||||
import shutil # noqa: PLC0415
|
||||
import shutil
|
||||
|
||||
python38 = shutil.which("python3.8")
|
||||
if python38 is None:
|
||||
@@ -142,7 +142,7 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
"""Only generate_pack.py and pipeline.py checked the version. verify.py,
|
||||
slots.py, validate_pr.py and cross_reference.py started under 3.8 and
|
||||
stopped halfway on a str.removeprefix AttributeError."""
|
||||
import shutil # noqa: PLC0415
|
||||
import shutil
|
||||
|
||||
python38 = shutil.which("python3.8")
|
||||
if python38 is None:
|
||||
@@ -179,7 +179,7 @@ class ReadmeRegressions(unittest.TestCase):
|
||||
Compiling only checks the grammar: a module-level alias such as
|
||||
`tuple[int, int | None]` compiles under 3.9 and raises TypeError
|
||||
when the module loads."""
|
||||
import shutil # noqa: PLC0415
|
||||
import shutil
|
||||
|
||||
floor = re.search(
|
||||
r"sys\.version_info < \((\d+), (\d+)\)",
|
||||
@@ -633,10 +633,9 @@ class APackIsSwappedInWhole(unittest.TestCase):
|
||||
pack = directory / "Pack.zip"
|
||||
with zipfile.ZipFile(pack, "w") as zf:
|
||||
zf.writestr("old.bin", b"complete")
|
||||
with self.assertRaises(OSError):
|
||||
with _writing_pack(str(pack)) as zf:
|
||||
zf.writestr("new.bin", b"half")
|
||||
raise OSError("disk full")
|
||||
with self.assertRaises(OSError), _writing_pack(str(pack)) as zf:
|
||||
zf.writestr("new.bin", b"half")
|
||||
raise OSError("disk full")
|
||||
with zipfile.ZipFile(pack) as zf:
|
||||
self.assertEqual(zf.namelist(), ["old.bin"])
|
||||
self.assertEqual(sorted(p.name for p in directory.iterdir()), ["Pack.zip"])
|
||||
@@ -1004,8 +1003,8 @@ class FaqRegressions(unittest.TestCase):
|
||||
# and FinalBurn Neo 1.0.0.2, versions no source at the pins states,
|
||||
# and the test holding them to the profiles kept the errors in step.
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
import generate_site # noqa: PLC0415
|
||||
from common import load_emulator_profiles # noqa: PLC0415
|
||||
import generate_site
|
||||
from common import load_emulator_profiles
|
||||
|
||||
profiles = load_emulator_profiles(str(ROOT / "emulators"), skip_aliases=False)
|
||||
page = (ROOT / "wiki" / "technical-faq.md").read_text(encoding="utf-8")
|
||||
@@ -1138,7 +1137,7 @@ class PipelineRegressions(unittest.TestCase):
|
||||
def test_integrity_checks_the_variants_step_4_built(self):
|
||||
"""Step 6 ran --verify-packs without --all-variants: the five
|
||||
narrowed packs were never opened and an empty _Platform passed."""
|
||||
import argparse # noqa: PLC0415
|
||||
import argparse
|
||||
|
||||
def command(**flags) -> list[str]:
|
||||
base = {"output_dir": "dist", "target": None, "all_variants": False}
|
||||
@@ -1331,7 +1330,7 @@ class SchemaFormatsAreChecked(unittest.TestCase):
|
||||
|
||||
@unittest.skipUnless(HAS_JSONSCHEMA, "validating a schema needs jsonschema")
|
||||
def test_a_missing_checker_is_named(self):
|
||||
import validate_schemas # noqa: PLC0415
|
||||
import validate_schemas
|
||||
|
||||
empty = mock.Mock(checkers={})
|
||||
with mock.patch.object(validate_schemas, "FormatChecker", return_value=empty):
|
||||
@@ -1878,7 +1877,7 @@ class RegionRegressions(unittest.TestCase):
|
||||
def test_region_audit_resolves_the_way_the_pack_does(self):
|
||||
"""A private resolver read sha1, md5 and a lone name: an entry
|
||||
identified by its path (Dolphin's three IPL.bin) was never checked."""
|
||||
import hashlib # noqa: PLC0415
|
||||
import hashlib
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
|
||||
previous = os.getcwd()
|
||||
@@ -1893,7 +1892,7 @@ class RegionRegressions(unittest.TestCase):
|
||||
files[sha1] = {"path": rel, "name": "IPL.bin", "size": len(payload), "sha1": sha1,
|
||||
"md5": hashlib.md5(payload).hexdigest(),
|
||||
"sha256": hashlib.sha256(payload).hexdigest(), "crc32": "00000001"}
|
||||
from scripts import generate_db # noqa: PLC0415
|
||||
from scripts import generate_db
|
||||
|
||||
db = {"files": files, "indexes": generate_db.build_indexes(files, {})}
|
||||
by_md5 = {e["md5"]: s for s, e in files.items()}
|
||||
@@ -3128,7 +3127,7 @@ class TheProjectInstallsWithPip(unittest.TestCase):
|
||||
discovery found scripts/ and tests/ and refused to build."""
|
||||
|
||||
def test_setuptools_discovers_nothing_to_package(self):
|
||||
import importlib.util # noqa: PLC0415
|
||||
import importlib.util
|
||||
|
||||
if importlib.util.find_spec("setuptools") is None:
|
||||
# The dev extra and CI install it: skipped there, the guard held
|
||||
@@ -3147,7 +3146,7 @@ class TheProjectInstallsWithPip(unittest.TestCase):
|
||||
capture_output=True, text=True, check=False)
|
||||
self.assertEqual(done.returncode, 0, done.stderr[-2000:])
|
||||
self.assertEqual(done.stdout.strip(), "[] []")
|
||||
import tomllib # noqa: PLC0415
|
||||
import tomllib
|
||||
|
||||
with (ROOT / "pyproject.toml").open("rb") as handle:
|
||||
build = tomllib.load(handle)["build-system"]
|
||||
@@ -3212,7 +3211,7 @@ class ACheckThatCannotAnswerDoesNotPass(unittest.TestCase):
|
||||
"""Every HEAD unanswered printed "16 unknown" and exited 0, so the
|
||||
online pipeline printed check_buildbot OK."""
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
import check_buildbot_system as cbs # noqa: PLC0415
|
||||
import check_buildbot_system as cbs
|
||||
|
||||
registry = str(ROOT / "platforms" / "_data_dirs.yml")
|
||||
tracked = cbs.load_tracked_entries(registry)
|
||||
@@ -3899,7 +3898,7 @@ class AnUnreadableArchiveIsSaidOutLoud(unittest.TestCase):
|
||||
truncated archive read as a missing dump (not_found) or a wrong one."""
|
||||
|
||||
def test_the_resolver_names_the_archive(self):
|
||||
import common # noqa: PLC0415
|
||||
import common
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
broken = Path(tmp) / "neogeo.zip"
|
||||
@@ -3922,7 +3921,7 @@ class GeneralUserGSReachesEveryCoreThatNamesIt(unittest.TestCase):
|
||||
shipped no General MIDI bank."""
|
||||
|
||||
def test_each_name_resolves_to_the_one_file(self):
|
||||
import common # noqa: PLC0415
|
||||
import common
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not generated")
|
||||
@@ -3946,7 +3945,7 @@ class APlatformPinDoesNotReplaceTheCoresRevision(unittest.TestCase):
|
||||
files to cores built against newer ones."""
|
||||
|
||||
def test_the_profile_revision_serves_the_core(self):
|
||||
import common # noqa: PLC0415
|
||||
import common
|
||||
|
||||
if not (ROOT / "database.json").exists():
|
||||
self.skipTest("database.json is not generated")
|
||||
@@ -3987,7 +3986,7 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase):
|
||||
resolution cost names x tree on every pack build."""
|
||||
|
||||
def test_two_lookups_share_one_walk_and_keep_its_order(self):
|
||||
import common # noqa: PLC0415
|
||||
import common
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as tmp:
|
||||
cache = Path(tmp) / "cache"
|
||||
@@ -4022,7 +4021,7 @@ class ADuplicateYamlKeyIsRefused(unittest.TestCase):
|
||||
target_source keys for Recalbox and nothing noticed."""
|
||||
|
||||
def test_the_loader_names_the_repeated_key(self):
|
||||
from safeparse import yaml_load # noqa: PLC0415
|
||||
from safeparse import yaml_load
|
||||
|
||||
with self.assertRaises(yaml.constructor.ConstructorError) as caught:
|
||||
yaml_load("platform: x\ntarget_source: a\ntarget_source: b\n")
|
||||
@@ -4229,7 +4228,7 @@ class TriageSurvivesAForgeRefusal(unittest.TestCase):
|
||||
def check_version(profile, *_args):
|
||||
if "eden" in profile["source"]:
|
||||
raise profile_sync.upstream.UpstreamError("HTTP 403")
|
||||
return None
|
||||
return
|
||||
|
||||
args = SimpleNamespace(cache_dir="", offline=True)
|
||||
out = io.StringIO()
|
||||
@@ -4289,7 +4288,7 @@ class OpenMsxRomsSitInItsSystemroms(unittest.TestCase):
|
||||
them there."""
|
||||
|
||||
def test_every_entry_is_under_share_systemroms(self):
|
||||
from scripts.common import ( # noqa: PLC0415
|
||||
from scripts.common import (
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
platform_layouts,
|
||||
@@ -4720,7 +4719,7 @@ class AReaderThatLeavesEarlyIsNoCrash(unittest.TestCase):
|
||||
# the close below never met the broken pipe and exited 0. A 4 KiB
|
||||
# pipe keeps it writing when the reader leaves.
|
||||
try:
|
||||
import fcntl # noqa: PLC0415
|
||||
import fcntl
|
||||
|
||||
fcntl.fcntl(proc.stdout.fileno(), fcntl.F_SETPIPE_SZ, 4096)
|
||||
except (ImportError, AttributeError, OSError):
|
||||
@@ -5670,7 +5669,7 @@ class AHeldRevisionLinksItsBuildFile(unittest.TestCase):
|
||||
f"RetroPie-Setup/blob/{pin}/scriptmodules/emulators/advmame-1.4.sh)", rows[0])
|
||||
|
||||
def test_the_record_holds_the_build_files(self):
|
||||
import sitesources # noqa: PLC0415
|
||||
import sitesources
|
||||
|
||||
files = sitesources.build_files({"pin_build": [
|
||||
{"repo": "https://github.com/o/r", "revision": "a" * 40, "path": "p.mk"},
|
||||
|
||||
@@ -959,7 +959,7 @@ class SubjectsFollowTheRepositoryRules(unittest.TestCase):
|
||||
calls: a copy in the hook alone let CI check only the shape."""
|
||||
|
||||
def test_the_runner_reads_the_tracked_rules(self):
|
||||
import commit_rules # noqa: PLC0415
|
||||
import commit_rules
|
||||
|
||||
for subject in ("chore: fix the broken manifests", "update things", "chore: " + "a" * 60):
|
||||
with self.subTest(subject=subject):
|
||||
@@ -970,7 +970,7 @@ class SubjectsFollowTheRepositoryRules(unittest.TestCase):
|
||||
def test_review_numbers_are_refused(self):
|
||||
"""47 pushed subjects pointed at a numbered private review, which no
|
||||
clone can follow. The subject says what the change does."""
|
||||
import commit_rules # noqa: PLC0415
|
||||
import commit_rules
|
||||
|
||||
for subject in ("chore: audit 24 and 17 cases, host kept out",
|
||||
"fix: polish the screens audit 11 named",
|
||||
|
||||
@@ -391,7 +391,7 @@ class SeveralAcceptedMd5BecomeAList(unittest.TestCase):
|
||||
"""Run the produced script: either listed md5 passes, another fails."""
|
||||
produced, _, _, _ = self._export([dict(self.CORRECTED, md5=[C, SECOND])], LISTING)
|
||||
namespace: dict = {"__name__": "batocera_systems"}
|
||||
exec(compile(produced, "batocera-systems", "exec"), namespace) # noqa: S102
|
||||
exec(compile(produced, "batocera-systems", "exec"), namespace)
|
||||
item = namespace["systems"]["psx"]["biosFiles"][0]
|
||||
self.assertEqual(item["md5"], [C, SECOND])
|
||||
scratch = REPO_ROOT / "tmp"
|
||||
|
||||
@@ -23,14 +23,14 @@ sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
class DeclaredFilesResolveWithoutDataCaches(unittest.TestCase):
|
||||
def test_no_platform_entry_rests_on_a_data_directory_cache(self):
|
||||
from common import ( # noqa: PLC0415
|
||||
from common import (
|
||||
build_zip_contents_index,
|
||||
list_registered_platforms,
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_platform_config,
|
||||
)
|
||||
from packresolve import resolve_declaration # noqa: PLC0415
|
||||
from packresolve import resolve_declaration
|
||||
|
||||
platforms_dir = REPO_ROOT / "platforms"
|
||||
registry = load_data_dir_registry(str(platforms_dir))
|
||||
|
||||
@@ -34,8 +34,8 @@ class APrimaryUnderAnotherCasing(unittest.TestCase):
|
||||
platform pins, in the same directory."""
|
||||
|
||||
def setUp(self):
|
||||
import shutil # noqa: PLC0415
|
||||
import tempfile # noqa: PLC0415
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, self.root, True)
|
||||
@@ -43,7 +43,7 @@ class APrimaryUnderAnotherCasing(unittest.TestCase):
|
||||
self.by_name: dict = {}
|
||||
|
||||
def _put(self, relative: str, data: bytes, indexed_as: str | None = None) -> None:
|
||||
import hashlib # noqa: PLC0415
|
||||
import hashlib
|
||||
|
||||
path = self.root / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
@@ -56,7 +56,7 @@ class APrimaryUnderAnotherCasing(unittest.TestCase):
|
||||
self.by_name.setdefault(name, []).append(sha1)
|
||||
|
||||
def _resolve(self, name: str) -> str:
|
||||
from common import _casefold_index_cache, resolve_local_file # noqa: PLC0415
|
||||
from common import _casefold_index_cache, resolve_local_file
|
||||
|
||||
_casefold_index_cache.clear()
|
||||
db = {"files": self.files, "indexes": {"by_name": self.by_name, "by_md5": {},
|
||||
|
||||
@@ -324,7 +324,7 @@ class CoreResolutionTests(unittest.TestCase):
|
||||
|
||||
def test_record_errors_are_one_line(self):
|
||||
"""A mistyped core and an empty offline cache ended on a traceback."""
|
||||
import subprocess # noqa: PLC0415
|
||||
import subprocess
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proc = subprocess.run(
|
||||
@@ -574,7 +574,7 @@ class ProfileSummaryTests(unittest.TestCase):
|
||||
def test_profile_sync_accepts_the_command_it_is_given(self):
|
||||
"""--json with the detection flags was refused, so --profiles read an
|
||||
empty stdout and reported "unreadable report" on every run."""
|
||||
import profile_sync # noqa: PLC0415
|
||||
import profile_sync
|
||||
|
||||
captured = []
|
||||
|
||||
@@ -653,8 +653,8 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
def test_a_target_of_every_declared_core_does_not_age(self):
|
||||
"""RetroBat, RetroDECK and RomM name one target that runs every core
|
||||
they declare. With nothing hand-kept, there is no date to watch."""
|
||||
import tempfile # noqa: PLC0415
|
||||
from pathlib import Path as _Path # noqa: PLC0415
|
||||
import tempfile
|
||||
from pathlib import Path as _Path
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
targets = _Path(tmp) / "targets"
|
||||
@@ -668,8 +668,8 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
def test_a_scraped_target_offline_is_skipped_not_ok(self):
|
||||
"""Offline, scraped target lists were labelled static and counted OK
|
||||
without any comparison, so a list 400 days old read as current."""
|
||||
import tempfile # noqa: PLC0415
|
||||
from pathlib import Path as _Path # noqa: PLC0415
|
||||
import tempfile
|
||||
from pathlib import Path as _Path
|
||||
|
||||
scraped = sorted(cf._target_scrapers())
|
||||
self.assertTrue(scraped)
|
||||
@@ -702,7 +702,7 @@ class RepositoryWiringTests(unittest.TestCase):
|
||||
|
||||
class RepeatedDestinations(unittest.TestCase):
|
||||
def test_a_change_to_an_earlier_declaration_is_seen(self):
|
||||
from check_freshness import diff_platform # noqa: PLC0415
|
||||
from check_freshness import diff_platform
|
||||
|
||||
def platform(first_md5: str) -> dict:
|
||||
return {"systems": {"pce": {"files": [
|
||||
@@ -716,7 +716,7 @@ class RepeatedDestinations(unittest.TestCase):
|
||||
|
||||
class PinsWithExtras(unittest.TestCase):
|
||||
def test_an_extras_bracket_keeps_its_pin(self):
|
||||
from check_freshness import parse_pip_pins # noqa: PLC0415
|
||||
from check_freshness import parse_pip_pins
|
||||
|
||||
pins = parse_pip_pins(' run: pip install pyyaml "jsonschema[format-nongpl]==4.26.0"')
|
||||
self.assertEqual(pins["jsonschema"], "==4.26.0")
|
||||
|
||||
@@ -15,7 +15,7 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
|
||||
|
||||
import build_port # noqa: E402
|
||||
import build_port
|
||||
from check_release import SIGNATURE, SUMS, Asset, compare_release, parse_sums
|
||||
|
||||
A = "a" * 64
|
||||
|
||||
@@ -16,8 +16,8 @@ import unittest
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
|
||||
|
||||
from common import platform_declared_contents # noqa: E402
|
||||
from validation import declaration_settles # noqa: E402
|
||||
from common import platform_declared_contents
|
||||
from validation import declaration_settles
|
||||
|
||||
SHA1 = "70cdf57469a208528f78a14275837352e90e20f1"
|
||||
DB = {
|
||||
|
||||
@@ -798,7 +798,7 @@ class TheInterpreterIsInTheSandbox(unittest.TestCase):
|
||||
crashed on the runner."""
|
||||
|
||||
def test_each_link_to_the_interpreter_is_bound(self):
|
||||
from unittest import mock # noqa: PLC0415
|
||||
from unittest import mock
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
@@ -826,7 +826,7 @@ class TheInterpreterIsInTheSandbox(unittest.TestCase):
|
||||
def test_a_link_in_a_shared_folder_binds_only_itself(self):
|
||||
"""~/.local/bin/python3 must not expose ~/.local: only the link file
|
||||
and the proven Python prefix behind it are bound."""
|
||||
from unittest import mock # noqa: PLC0415
|
||||
from unittest import mock
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
|
||||
@@ -62,7 +62,7 @@ def _ecdsa_sign(message: bytes) -> bytes:
|
||||
g = (ec._Gx, ec._Gy)
|
||||
r = ec._ec_mul(_ECC_NONCE, g)[0] % ec._N
|
||||
digest = int.from_bytes(hashlib.sha256(message).digest(), "big")
|
||||
if 256 > ec._N_BITLEN:
|
||||
if ec._N_BITLEN < 256:
|
||||
digest >>= 256 - ec._N_BITLEN
|
||||
s = (ec._modinv(_ECC_NONCE, ec._N) * (digest + r * _ECC_PRIVATE)) % ec._N
|
||||
return r.to_bytes(30, "big") + s.to_bytes(30, "big")
|
||||
|
||||
@@ -118,7 +118,7 @@ def _sign(message: bytes, private: int, nonce: int) -> bytes:
|
||||
point = ec._ec_mul(nonce, g)
|
||||
r = point[0] % ec._N
|
||||
digest = int.from_bytes(hashlib.sha256(message).digest(), "big")
|
||||
if 256 > ec._N_BITLEN:
|
||||
if ec._N_BITLEN < 256:
|
||||
digest >>= 256 - ec._N_BITLEN
|
||||
s = (ec._modinv(nonce, ec._N) * (digest + r * private)) % ec._N
|
||||
return r.to_bytes(30, "big") + s.to_bytes(30, "big")
|
||||
|
||||
@@ -30,7 +30,7 @@ class FlatDeclaredSet(unittest.TestCase):
|
||||
another that no alias joins: per system the ids never meet.
|
||||
nintendo-sgb and nintendo-super-game-boy were such a pair until
|
||||
SYSTEM_ALIASES joined them."""
|
||||
import tempfile # noqa: PLC0415
|
||||
import tempfile
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
platforms = Path(tmp)
|
||||
|
||||
+4
-4
@@ -302,7 +302,7 @@ class TheNoDedupListIsPinned(unittest.TestCase):
|
||||
three machines again, with the suite green."""
|
||||
|
||||
def test_every_tree_read_by_path_stays_undeduplicated(self):
|
||||
from scripts.dedup import NODEDUP_DIRS # noqa: PLC0415
|
||||
from scripts.dedup import NODEDUP_DIRS
|
||||
|
||||
expected = {
|
||||
"RPG Maker", "ScummVM", "tzdata", "c64-emu", "PinMAME", "BBK",
|
||||
@@ -350,7 +350,7 @@ class CloneChainsCollapse(unittest.TestCase):
|
||||
pointed at a file that no longer existed."""
|
||||
|
||||
def test_clones_follow_to_the_canonical_that_exists(self):
|
||||
import dedup # noqa: PLC0415
|
||||
import dedup
|
||||
|
||||
chain = {
|
||||
"cpu20.zip": {"clones": ["cpu21.zip"], "sha1": "a", "total_copies": 1},
|
||||
@@ -362,7 +362,7 @@ class CloneChainsCollapse(unittest.TestCase):
|
||||
})
|
||||
|
||||
def test_a_loop_is_refused(self):
|
||||
import dedup # noqa: PLC0415
|
||||
import dedup
|
||||
|
||||
loop = {"a.zip": {"clones": ["b.zip"]}, "b.zip": {"clones": ["a.zip"]}}
|
||||
with self.assertRaises(ValueError):
|
||||
@@ -370,4 +370,4 @@ class CloneChainsCollapse(unittest.TestCase):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
unittest.main()
|
||||
@@ -236,7 +236,7 @@ class PackCarriesADirectory(DirectoryFixture):
|
||||
self.assertEqual(
|
||||
archive.read("rtp/2000/Backdrop/a.png"), b"backdrop"
|
||||
)
|
||||
self.assertTrue(self.EXPECTED <= names, sorted(names))
|
||||
self.assertTrue(names >= self.EXPECTED, sorted(names))
|
||||
self.assertFalse([n for n in names if ".variants" in n])
|
||||
|
||||
def test_the_install_manifest_lists_the_tree(self):
|
||||
@@ -248,7 +248,7 @@ class PackCarriesADirectory(DirectoryFixture):
|
||||
offline=True,
|
||||
)
|
||||
dests = {entry["dest"] for entry in manifest["files"]}
|
||||
self.assertTrue(self.EXPECTED <= dests, sorted(dests))
|
||||
self.assertTrue(dests >= self.EXPECTED, sorted(dests))
|
||||
json.dumps(manifest)
|
||||
|
||||
def test_the_gap_report_is_computed_once_per_build(self):
|
||||
@@ -291,7 +291,7 @@ class PackCarriesADirectory(DirectoryFixture):
|
||||
)
|
||||
with zipfile.ZipFile(zip_path) as archive:
|
||||
names = set(archive.namelist())
|
||||
self.assertTrue(self.EXPECTED <= names, sorted(names))
|
||||
self.assertTrue(names >= self.EXPECTED, sorted(names))
|
||||
|
||||
def test_verify_counts_what_the_emulator_pack_ships(self):
|
||||
self._profiles()
|
||||
|
||||
+11
-11
@@ -1318,7 +1318,7 @@ class CitedOptionsExist(unittest.TestCase):
|
||||
def help_text(cls, target: str, module: bool, sub: str = "") -> str:
|
||||
key = (target, sub)
|
||||
if key not in cls._helps:
|
||||
import subprocess # noqa: PLC0415
|
||||
import subprocess
|
||||
|
||||
argv = [sys.executable, *(["-m", target] if module else [target])]
|
||||
proc = subprocess.run(
|
||||
@@ -1376,7 +1376,7 @@ class PipelineStepsMatchTheRun(unittest.TestCase):
|
||||
|
||||
@staticmethod
|
||||
def labels() -> list[str]:
|
||||
import pipeline # noqa: PLC0415
|
||||
import pipeline
|
||||
|
||||
return [pipeline.step_number(key) for key in pipeline.STEP_LABELS]
|
||||
|
||||
@@ -1739,7 +1739,7 @@ class ArchitectureStatesTheArbitration(unittest.TestCase):
|
||||
checks the content: RetroBat's ATARIOSB.ROM."""
|
||||
|
||||
def test_the_page_says_what_arbitrate_decides(self):
|
||||
import slots # noqa: PLC0415
|
||||
import slots
|
||||
|
||||
page = (WIKI / "architecture.md").read_text(encoding="utf-8")
|
||||
self.assertNotIn("the profile takes precedence for pack generation", page)
|
||||
@@ -1795,9 +1795,9 @@ class ReportExcerptIsTheRun(unittest.TestCase):
|
||||
naming one, and never showed the line that names it."""
|
||||
|
||||
def test_every_quoted_line_is_printed(self):
|
||||
import subprocess # noqa: PLC0415
|
||||
import subprocess
|
||||
|
||||
from restore_large_files import gitignored_paths # noqa: PLC0415
|
||||
from restore_large_files import gitignored_paths
|
||||
|
||||
# The excerpt is a run over the whole collection. A checkout without
|
||||
# the release assets (the PR workflow restores none) prints other
|
||||
@@ -1915,7 +1915,7 @@ class TheInstallerSamplesTravelWithTheManifests(unittest.TestCase):
|
||||
place for the samples the gate's pipeline rewrites."""
|
||||
|
||||
def test_the_pages_and_the_nightly_carry_them(self):
|
||||
import autorun # noqa: PLC0415
|
||||
import autorun
|
||||
|
||||
guide = (WIKI / "testing-guide.md").read_text(encoding="utf-8")
|
||||
for name in ("wiki/installer.md", "derivable.json", "generate_installer_doc.py"):
|
||||
@@ -1940,7 +1940,7 @@ class TheRemovalProofsAreTheExportersOwn(unittest.TestCase):
|
||||
"data_directory": "a data directory"}
|
||||
|
||||
def test_the_page_names_each_proof_in_order(self):
|
||||
from exporter.candidates import _PROOF_ORDER # noqa: PLC0415
|
||||
from exporter.candidates import _PROOF_ORDER
|
||||
|
||||
page = (WIKI / "tools.md").read_text(encoding="utf-8")
|
||||
start = page.index("No entry the platform declares is removed.")
|
||||
@@ -1969,10 +1969,10 @@ class NoTextClaimsAScheduledScrape(unittest.TestCase):
|
||||
`schedule:`."""
|
||||
|
||||
def test_no_text_ties_the_registry_to_automation(self):
|
||||
import generate_pack # noqa: PLC0415
|
||||
import generate_readme # noqa: PLC0415
|
||||
import generate_site # noqa: PLC0415
|
||||
import list_platforms # noqa: PLC0415
|
||||
import generate_pack
|
||||
import generate_readme
|
||||
import generate_site
|
||||
import list_platforms
|
||||
|
||||
texts = {
|
||||
"adding-a-platform.md": (WIKI / "adding-a-platform.md").read_text(encoding="utf-8"),
|
||||
|
||||
@@ -85,9 +85,9 @@ class TheDownloadTablesFollowTheRegistry(unittest.TestCase):
|
||||
now: the row of each platform names every system it is detected on."""
|
||||
|
||||
def test_every_detected_system_lists_the_platform(self):
|
||||
import yaml # noqa: PLC0415
|
||||
import yaml
|
||||
|
||||
from common import load_platform_config # noqa: PLC0415
|
||||
from common import load_platform_config
|
||||
|
||||
registry = yaml.safe_load(_read("platforms/_registry.yml"))
|
||||
page = _which_pack()
|
||||
@@ -431,7 +431,7 @@ class PagesOpenOnTheirContent(unittest.TestCase):
|
||||
before saying anything about a pack."""
|
||||
|
||||
def test_no_paragraph_announces_its_page(self):
|
||||
import generate_site # noqa: PLC0415
|
||||
import generate_site
|
||||
|
||||
text = generate_site.generate_which_pack()
|
||||
announcing = [
|
||||
@@ -648,7 +648,7 @@ class ArchiveRecipesAreCountedFromTheRecipes(unittest.TestCase):
|
||||
that file, never typed."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
import archive_build # noqa: PLC0415
|
||||
import archive_build
|
||||
|
||||
records = archive_build.load_ledger().values()
|
||||
self.counts = {
|
||||
@@ -660,7 +660,7 @@ class ArchiveRecipesAreCountedFromTheRecipes(unittest.TestCase):
|
||||
self.assertEqual(self.counts["exact"] + self.counts["canonical"], self.counts["total"])
|
||||
|
||||
def test_the_readme_line(self) -> None:
|
||||
from generate_readme import archive_line # noqa: PLC0415
|
||||
from generate_readme import archive_line
|
||||
|
||||
line = archive_line(self.counts)
|
||||
self.assertIn(line, _read("README.md").splitlines())
|
||||
@@ -670,7 +670,7 @@ class ArchiveRecipesAreCountedFromTheRecipes(unittest.TestCase):
|
||||
self.assertIn(f"({SITE_URL}wiki/archive-recipes/)", line)
|
||||
|
||||
def test_the_page_counts(self) -> None:
|
||||
import generate_site # noqa: PLC0415
|
||||
import generate_site
|
||||
|
||||
page = _read("wiki/archive-recipes.md")
|
||||
self.assertEqual(generate_site.with_archive_counts(page, self.counts), page,
|
||||
|
||||
@@ -102,9 +102,8 @@ class TestPackGrouping(unittest.TestCase):
|
||||
def test_info_on_an_unknown_platform_fails(self):
|
||||
"""--info printed "not found" and exited 0."""
|
||||
release = _release(["EmuDeck_2.3.8_BIOS_Pack.zip"])
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
download.show_info("emudek", release)
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out, self.assertRaises(SystemExit) as caught:
|
||||
download.show_info("emudek", release)
|
||||
self.assertEqual(caught.exception.code, 1)
|
||||
self.assertIn("EmuDeck", out.getvalue())
|
||||
|
||||
|
||||
+4
-4
@@ -6504,9 +6504,9 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
gap report (system, systems) to platform_region_groups, not a
|
||||
dictionary built by hand. Without it every extra stood alone and
|
||||
--region compared nothing."""
|
||||
import hashlib # noqa: PLC0415
|
||||
import hashlib
|
||||
|
||||
from packextras import platform_region_groups # noqa: PLC0415
|
||||
from packextras import platform_region_groups
|
||||
|
||||
files, by_name = {}, {}
|
||||
for name in ("core_us.bin", "core_jp.bin"):
|
||||
@@ -6542,9 +6542,9 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
"""RetroDECK files the Master System as sega-master-system, the
|
||||
profiles as sega-mastersystem. Two groups reduced apart, and a
|
||||
--region us pack kept the declared Japanese BIOS."""
|
||||
import hashlib # noqa: PLC0415
|
||||
import hashlib
|
||||
|
||||
from packextras import platform_region_groups # noqa: PLC0415
|
||||
from packextras import platform_region_groups
|
||||
|
||||
files, by_name = {}, {}
|
||||
for name in ("bios_U.sms", "bios_J.sms"):
|
||||
|
||||
@@ -250,7 +250,7 @@ class TheFrontendOffersWhatTheDeviceKeeps(unittest.TestCase):
|
||||
|
||||
class TheCommittedListFollowsTheRules(unittest.TestCase):
|
||||
def test_the_handhelds_list_no_core_they_do_not_build(self):
|
||||
import yaml # noqa: PLC0415
|
||||
import yaml
|
||||
|
||||
targets = yaml.safe_load((REPO_ROOT / "platforms" / "targets" / "emuelec.yml")
|
||||
.read_text(encoding="utf-8"))["targets"]
|
||||
|
||||
@@ -81,9 +81,9 @@ class APlaceholderIsAnsweredByEvidence(unittest.TestCase):
|
||||
import yaml
|
||||
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
from common import _emulator_profiles_cache # noqa: PLC0415
|
||||
from generate_pack import generate_emulator_pack # noqa: PLC0415
|
||||
from verify import verify_emulator # noqa: PLC0415
|
||||
from common import _emulator_profiles_cache
|
||||
from generate_pack import generate_emulator_pack
|
||||
from verify import verify_emulator
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
|
||||
@@ -14,8 +14,8 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
|
||||
|
||||
import verify # noqa: E402
|
||||
from exporter.candidates import ( # noqa: E402
|
||||
import verify
|
||||
from exporter.candidates import (
|
||||
BIOS,
|
||||
GAME_DATA,
|
||||
UNREAD,
|
||||
|
||||
Loaded 100 of 186 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user