mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: one owner per installer source decision
--emulator says its Narrowed line through detail, as every other narrowing. Detection records that it read the RetroArch configs, and a lookup detects again only before that, held by detection_held. The list and pack open apart from the --from folders, whose refusal one function builds for line mode and the full screen.
This commit is contained in:
1 parent
18472f9d0f
commit
2b5031ecd6
15 files changed
+121
-89
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 = "c7cb1bc14b2da10866815f3d988df998f0c6bc17e919e33117435df74a00894e"
|
||||
$defaultInstallSha256 = "0772b655a6313237ddfe2fcd45386e732b5ed37542fb22c146b4908f35ce09cf"
|
||||
# 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
|
||||
|
||||
+48
-33
@@ -2076,6 +2076,9 @@ def _retroarch_cfg_dir(
|
||||
# System directory -> the retroarch.cfg it was read from and the directory
|
||||
# ':' expands to there, for finding the cores of the same installation.
|
||||
_RETROARCH_CONFIGS: dict[Path, tuple[Path, Path]] = {}
|
||||
# Set by detection once it has read the configs: a lookup after it finds
|
||||
# nothing more by detecting again.
|
||||
_CONFIGS_READ: list[bool] = []
|
||||
|
||||
|
||||
def _parse_retroarch_system_dir(
|
||||
@@ -5910,6 +5913,8 @@ def _without_unnameable(found: list[tuple[str, Path]]) -> list[tuple[str, Path]]
|
||||
@_detection_guarded
|
||||
def detect_platforms(os_type: str) -> list[tuple[str, Path]]:
|
||||
"""Detect installed emulator platforms and their BIOS directories."""
|
||||
if not _CONFIGS_READ:
|
||||
_CONFIGS_READ.append(True)
|
||||
found: list[tuple[str, Path]] = []
|
||||
if os_type == "wsl":
|
||||
_note_windows_unasked()
|
||||
@@ -6264,9 +6269,6 @@ def version_note(plat: str, bios_path: Path, manifest: dict) -> tuple[str, str,
|
||||
|
||||
# --- installer/frontend_folders.py -------------------------------------------
|
||||
|
||||
_CONFIGS_READ: list[bool] = []
|
||||
|
||||
|
||||
def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
|
||||
"""The retroarch.cfg whose system_directory is bios_path, and the
|
||||
folder ':' expands to there.
|
||||
@@ -6280,13 +6282,11 @@ def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
|
||||
found = _retroarch_config_at(bios_path)
|
||||
if found is not None or _CONFIGS_READ:
|
||||
return found
|
||||
_CONFIGS_READ.append(True)
|
||||
# Silent, the unsearched event too: this run searched for no setup, and
|
||||
# the event came after detect, the line it stands for never shown.
|
||||
_SETUP_SEARCH.quiet = True
|
||||
try:
|
||||
with contextlib.redirect_stdout(io.StringIO()), \
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
with detection_held():
|
||||
detect_platforms(_INVOCATION.os_type or detect_os())
|
||||
finally:
|
||||
_SETUP_SEARCH.quiet = False
|
||||
@@ -11010,8 +11010,9 @@ def _narrowing_advice(plat: str, axis: str, flag: str, recorded: frozenset,
|
||||
def _narrow_to_emulators(
|
||||
names: list[str], manifest: dict, plat: str,
|
||||
files: list[dict], omitted: list[dict],
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Keep what the named emulators read, as the pack built for them.
|
||||
) -> tuple[list[str], list[dict], list[dict]]:
|
||||
"""(names chosen, files, omitted): what the named emulators read, as the
|
||||
pack built for them.
|
||||
|
||||
An emulator page offers this as one command, so a name the platform
|
||||
does not run is refused rather than read as nothing to install.
|
||||
@@ -11025,7 +11026,6 @@ def _narrow_to_emulators(
|
||||
chosen = resolve_choices(names, known, "emulator")
|
||||
except ValueError as exc:
|
||||
refuse_name(plat, f"Error: {plat}: {exc}")
|
||||
before = len(files)
|
||||
files, omitted = narrow_to_cores(manifest, chosen, files, omitted)
|
||||
# A whole-platform install keeps the platform's files of a system no
|
||||
# core is mapped to. Here only the named emulators' systems are wanted.
|
||||
@@ -11040,8 +11040,7 @@ def _narrow_to_emulators(
|
||||
|
||||
files = [entry for entry in files if theirs(entry)]
|
||||
omitted = [entry for entry in omitted if theirs(entry)]
|
||||
print(f" Narrowed {before} to {len(files)} files to {', '.join(chosen)}")
|
||||
return files, omitted
|
||||
return chosen, files, omitted
|
||||
|
||||
|
||||
def _standalone_builds(
|
||||
@@ -12687,12 +12686,23 @@ def sources_line(
|
||||
|
||||
|
||||
def _open_local_sources(args: argparse.Namespace) -> None:
|
||||
"""Take the file list and the pack this run was given, and the platform
|
||||
they are for when none is named."""
|
||||
"""Line mode's sources: the --from folders read, then the file list and
|
||||
the pack this run was given."""
|
||||
reset_local_sources(args)
|
||||
open_from_folders(getattr(args, "from", None) or [])
|
||||
open_list_and_pack(args)
|
||||
|
||||
|
||||
def reset_local_sources(args: argparse.Namespace) -> None:
|
||||
"""Forget the sources and failures a previous run in this process kept."""
|
||||
LOCAL.reset()
|
||||
LOCAL.jobs = getattr(args, "jobs", 8) or 8
|
||||
SAID_FAILED.clear()
|
||||
_open_from_folders(getattr(args, "from", None) or [])
|
||||
|
||||
|
||||
def open_list_and_pack(args: argparse.Namespace) -> None:
|
||||
"""Take the file list and the pack this run was given, and the platform
|
||||
they are for when none is named."""
|
||||
if args.manifest is not None:
|
||||
LOCAL.manifest = args.manifest
|
||||
named = local_manifest_platform(args.manifest)
|
||||
@@ -12773,16 +12783,23 @@ def from_folder_problem(label: str) -> tuple[str, str] | None:
|
||||
return ("system", system) if system else None
|
||||
|
||||
|
||||
def _open_from_folders(folders: list[Path]) -> None:
|
||||
def from_folder_refusal(label: str) -> Refusal | None:
|
||||
"""The refusal of a folder named with --from that cannot be read, or None."""
|
||||
problem = from_folder_problem(label)
|
||||
if problem is None:
|
||||
return None
|
||||
reason, what = problem
|
||||
message = f"{label} {what}: --from names the folder to copy BIOS files from"
|
||||
return Refusal("from", reason, "", f"Error: {screen_text(message)}.", message=message)
|
||||
|
||||
|
||||
def open_from_folders(folders: list[Path]) -> None:
|
||||
"""Read each folder named with --from, or stop on one that cannot be."""
|
||||
for folder in folders:
|
||||
label = str(folder)
|
||||
problem = from_folder_problem(label)
|
||||
if problem is not None:
|
||||
reason, what = problem
|
||||
message = f"{label} {what}: --from names the folder to copy BIOS files from"
|
||||
raise Refusal("from", reason, "", f"Error: {screen_text(message)}.",
|
||||
message=message)
|
||||
refusal = from_folder_refusal(label)
|
||||
if refusal is not None:
|
||||
raise refusal
|
||||
_read_from_folder(label)
|
||||
|
||||
|
||||
@@ -22291,9 +22308,11 @@ def _pass_emulators(run: _InstallRun, p: _PlatformPass) -> bool:
|
||||
_recorded_emulators(args, p.plat_name, p.manifest, p.files, p.omitted_files)
|
||||
if args.emulator:
|
||||
names = emulator_names(p.manifest, p.files, p.omitted_files)
|
||||
p.files, p.omitted_files = _narrow_to_emulators(
|
||||
before = len(p.files)
|
||||
chosen, p.files, p.omitted_files = _narrow_to_emulators(
|
||||
args.emulator, p.manifest, p.plat_name, p.files, p.omitted_files
|
||||
)
|
||||
detail(f" Narrowed {before} to {len(p.files)} files to {', '.join(chosen)}")
|
||||
if args.standalone:
|
||||
p.files, p.omitted_files = _standalone_builds(
|
||||
args.emulator, names, p.manifest, p.plat_name, p.files, p.omitted_files)
|
||||
@@ -31869,19 +31888,15 @@ def _tui_startup(args: argparse.Namespace) -> tuple[TuiState, list[tuple]] | Non
|
||||
if os_type == "wsl":
|
||||
_enter_wsl()
|
||||
_wsl_dest(args)
|
||||
reset_local_sources(args)
|
||||
open_list_and_pack(args)
|
||||
# The --from folders are read by each check, not here: indexing a large
|
||||
# card held the first frame back. Only whether each can be read is asked.
|
||||
folders = getattr(args, "from") or []
|
||||
setattr(args, "from", None)
|
||||
try:
|
||||
_open_local_sources(args)
|
||||
finally:
|
||||
setattr(args, "from", folders)
|
||||
for folder in folders:
|
||||
problem = from_folder_problem(str(folder))
|
||||
if problem is not None:
|
||||
print(f"Error: {screen_text(str(folder))} {problem[1]}: --from names the folder "
|
||||
"to copy BIOS files from.", file=sys.stderr)
|
||||
for folder in getattr(args, "from") or []:
|
||||
refusal = from_folder_refusal(str(folder))
|
||||
if refusal is not None:
|
||||
for line in refusal.lines:
|
||||
print(line, file=sys.stderr)
|
||||
return None
|
||||
return tui_start(args, os_type)
|
||||
|
||||
|
||||
+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="c7cb1bc14b2da10866815f3d988df998f0c6bc17e919e33117435df74a00894e"
|
||||
DEFAULT_INSTALL_SHA256="0772b655a6313237ddfe2fcd45386e732b5ed37542fb22c146b4908f35ce09cf"
|
||||
# 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": 1475878,
|
||||
"sha256": "c7cb1bc14b2da10866815f3d988df998f0c6bc17e919e33117435df74a00894e",
|
||||
"size": 1476406,
|
||||
"sha256": "0772b655a6313237ddfe2fcd45386e732b5ed37542fb22c146b4908f35ce09cf",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1529503,
|
||||
"sha256": "3661582ac01d9b6d3cb48adadf4b297fe5d540e9e2e129fa56655bbf85554eed"
|
||||
"size": 1530031,
|
||||
"sha256": "73d52c29e416292b30962061f8c00721ad5fb42ea64decdd7b72c3979b84386d"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1475878,
|
||||
"sha256": "c7cb1bc14b2da10866815f3d988df998f0c6bc17e919e33117435df74a00894e",
|
||||
"size": 1476406,
|
||||
"sha256": "0772b655a6313237ddfe2fcd45386e732b5ed37542fb22c146b4908f35ce09cf",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1475878,
|
||||
"sha256": "c7cb1bc14b2da10866815f3d988df998f0c6bc17e919e33117435df74a00894e",
|
||||
"size": 1476406,
|
||||
"sha256": "0772b655a6313237ddfe2fcd45386e732b5ed37542fb22c146b4908f35ce09cf",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -340,8 +340,9 @@ def _narrowing_advice(plat: str, axis: str, flag: str, recorded: frozenset,
|
||||
def _narrow_to_emulators(
|
||||
names: list[str], manifest: dict, plat: str,
|
||||
files: list[dict], omitted: list[dict],
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Keep what the named emulators read, as the pack built for them.
|
||||
) -> tuple[list[str], list[dict], list[dict]]:
|
||||
"""(names chosen, files, omitted): what the named emulators read, as the
|
||||
pack built for them.
|
||||
|
||||
An emulator page offers this as one command, so a name the platform
|
||||
does not run is refused rather than read as nothing to install.
|
||||
@@ -355,7 +356,6 @@ def _narrow_to_emulators(
|
||||
chosen = resolve_choices(names, known, "emulator")
|
||||
except ValueError as exc:
|
||||
refuse_name(plat, f"Error: {plat}: {exc}")
|
||||
before = len(files)
|
||||
files, omitted = narrow_to_cores(manifest, chosen, files, omitted)
|
||||
# A whole-platform install keeps the platform's files of a system no
|
||||
# core is mapped to. Here only the named emulators' systems are wanted.
|
||||
@@ -370,8 +370,7 @@ def _narrow_to_emulators(
|
||||
|
||||
files = [entry for entry in files if theirs(entry)]
|
||||
omitted = [entry for entry in omitted if theirs(entry)]
|
||||
print(f" Narrowed {before} to {len(files)} files to {', '.join(chosen)}")
|
||||
return files, omitted
|
||||
return chosen, files, omitted
|
||||
|
||||
|
||||
def _standalone_builds(
|
||||
|
||||
@@ -59,6 +59,9 @@ def _retroarch_cfg_dir(
|
||||
# System directory -> the retroarch.cfg it was read from and the directory
|
||||
# ':' expands to there, for finding the cores of the same installation.
|
||||
_RETROARCH_CONFIGS: dict[Path, tuple[Path, Path]] = {}
|
||||
# Set by detection once it has read the configs: a lookup after it finds
|
||||
# nothing more by detecting again.
|
||||
_CONFIGS_READ: list[bool] = []
|
||||
|
||||
|
||||
def _parse_retroarch_system_dir(
|
||||
|
||||
@@ -10,6 +10,7 @@ from collections.abc import Callable, Iterator
|
||||
from pathlib import Path
|
||||
|
||||
from installer.config_values import (
|
||||
_CONFIGS_READ,
|
||||
_parse_bash_var,
|
||||
_parse_json_path,
|
||||
_parse_ps1_var,
|
||||
@@ -826,6 +827,8 @@ def _without_unnameable(found: list[tuple[str, Path]]) -> list[tuple[str, Path]]
|
||||
@_detection_guarded
|
||||
def detect_platforms(os_type: str) -> list[tuple[str, Path]]:
|
||||
"""Detect installed emulator platforms and their BIOS directories."""
|
||||
if not _CONFIGS_READ:
|
||||
_CONFIGS_READ.append(True)
|
||||
found: list[tuple[str, Path]] = []
|
||||
if os_type == "wsl":
|
||||
_note_windows_unasked()
|
||||
|
||||
+28
-10
@@ -803,12 +803,23 @@ def sources_line(
|
||||
|
||||
|
||||
def _open_local_sources(args: argparse.Namespace) -> None:
|
||||
"""Take the file list and the pack this run was given, and the platform
|
||||
they are for when none is named."""
|
||||
"""Line mode's sources: the --from folders read, then the file list and
|
||||
the pack this run was given."""
|
||||
reset_local_sources(args)
|
||||
open_from_folders(getattr(args, "from", None) or [])
|
||||
open_list_and_pack(args)
|
||||
|
||||
|
||||
def reset_local_sources(args: argparse.Namespace) -> None:
|
||||
"""Forget the sources and failures a previous run in this process kept."""
|
||||
LOCAL.reset()
|
||||
LOCAL.jobs = getattr(args, "jobs", 8) or 8
|
||||
SAID_FAILED.clear()
|
||||
_open_from_folders(getattr(args, "from", None) or [])
|
||||
|
||||
|
||||
def open_list_and_pack(args: argparse.Namespace) -> None:
|
||||
"""Take the file list and the pack this run was given, and the platform
|
||||
they are for when none is named."""
|
||||
if args.manifest is not None:
|
||||
LOCAL.manifest = args.manifest
|
||||
named = local_manifest_platform(args.manifest)
|
||||
@@ -889,16 +900,23 @@ def from_folder_problem(label: str) -> tuple[str, str] | None:
|
||||
return ("system", system) if system else None
|
||||
|
||||
|
||||
def _open_from_folders(folders: list[Path]) -> None:
|
||||
def from_folder_refusal(label: str) -> Refusal | None:
|
||||
"""The refusal of a folder named with --from that cannot be read, or None."""
|
||||
problem = from_folder_problem(label)
|
||||
if problem is None:
|
||||
return None
|
||||
reason, what = problem
|
||||
message = f"{label} {what}: --from names the folder to copy BIOS files from"
|
||||
return Refusal("from", reason, "", f"Error: {screen_text(message)}.", message=message)
|
||||
|
||||
|
||||
def open_from_folders(folders: list[Path]) -> None:
|
||||
"""Read each folder named with --from, or stop on one that cannot be."""
|
||||
for folder in folders:
|
||||
label = str(folder)
|
||||
problem = from_folder_problem(label)
|
||||
if problem is not None:
|
||||
reason, what = problem
|
||||
message = f"{label} {what}: --from names the folder to copy BIOS files from"
|
||||
raise Refusal("from", reason, "", f"Error: {screen_text(message)}.",
|
||||
message=message)
|
||||
refusal = from_folder_refusal(label)
|
||||
if refusal is not None:
|
||||
raise refusal
|
||||
_read_from_folder(label)
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"""The folders a frontend names besides its BIOS folder: saves, roms, configs and emulators."""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path, PurePosixPath
|
||||
|
||||
from installer.config_values import (
|
||||
_CONFIGS_READ,
|
||||
_RETROARCH_CONFIGS,
|
||||
_cfg_true,
|
||||
_config_keys,
|
||||
@@ -18,6 +17,7 @@ from installer.config_values import (
|
||||
from installer.console import detail
|
||||
from installer.detect_frontends import detect_platforms
|
||||
from installer.detect_os import detect_os
|
||||
from installer.detection_notes import detection_held
|
||||
from installer.events import EVENTS
|
||||
from installer.host_fs import _SETUP_SEARCH, _is_dir
|
||||
from installer.invocation import _INVOCATION
|
||||
@@ -36,8 +36,6 @@ from installer.paths import (
|
||||
)
|
||||
from installer.text import _plural
|
||||
|
||||
_CONFIGS_READ: list[bool] = []
|
||||
|
||||
|
||||
def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
|
||||
"""The retroarch.cfg whose system_directory is bios_path, and the
|
||||
@@ -52,13 +50,11 @@ def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
|
||||
found = _retroarch_config_at(bios_path)
|
||||
if found is not None or _CONFIGS_READ:
|
||||
return found
|
||||
_CONFIGS_READ.append(True)
|
||||
# Silent, the unsearched event too: this run searched for no setup, and
|
||||
# the event came after detect, the line it stands for never shown.
|
||||
_SETUP_SEARCH.quiet = True
|
||||
try:
|
||||
with contextlib.redirect_stdout(io.StringIO()), \
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
with detection_held():
|
||||
detect_platforms(_INVOCATION.os_type or detect_os())
|
||||
finally:
|
||||
_SETUP_SEARCH.quiet = False
|
||||
|
||||
@@ -470,9 +470,11 @@ def _pass_emulators(run: _InstallRun, p: _PlatformPass) -> bool:
|
||||
_recorded_emulators(args, p.plat_name, p.manifest, p.files, p.omitted_files)
|
||||
if args.emulator:
|
||||
names = emulator_names(p.manifest, p.files, p.omitted_files)
|
||||
p.files, p.omitted_files = _narrow_to_emulators(
|
||||
before = len(p.files)
|
||||
chosen, p.files, p.omitted_files = _narrow_to_emulators(
|
||||
args.emulator, p.manifest, p.plat_name, p.files, p.omitted_files
|
||||
)
|
||||
detail(f" Narrowed {before} to {len(p.files)} files to {', '.join(chosen)}")
|
||||
if args.standalone:
|
||||
p.files, p.omitted_files = _standalone_builds(
|
||||
args.emulator, names, p.manifest, p.plat_name, p.files, p.omitted_files)
|
||||
|
||||
@@ -32,7 +32,7 @@ from installer.destination import card_choice, dest_default
|
||||
from installer.detect_frontends import detect_frontends
|
||||
from installer.detection_notes import DETECTION_NOTES, detection_held
|
||||
from installer.detect_os import _enter_wsl, _wsl_dest, detect_os, detected_os
|
||||
from installer.from_folders import _open_local_sources, from_folder_problem
|
||||
from installer.from_folders import from_folder_refusal, open_list_and_pack, reset_local_sources
|
||||
from installer.host_fs import _DETECTION_REFUSED, refused_words
|
||||
from installer.install_record import choice_given
|
||||
from installer.invocation import _INVOCATION
|
||||
@@ -874,19 +874,15 @@ def _tui_startup(args: argparse.Namespace) -> tuple[TuiState, list[tuple]] | Non
|
||||
if os_type == "wsl":
|
||||
_enter_wsl()
|
||||
_wsl_dest(args)
|
||||
reset_local_sources(args)
|
||||
open_list_and_pack(args)
|
||||
# The --from folders are read by each check, not here: indexing a large
|
||||
# card held the first frame back. Only whether each can be read is asked.
|
||||
folders = getattr(args, "from") or []
|
||||
setattr(args, "from", None)
|
||||
try:
|
||||
_open_local_sources(args)
|
||||
finally:
|
||||
setattr(args, "from", folders)
|
||||
for folder in folders:
|
||||
problem = from_folder_problem(str(folder))
|
||||
if problem is not None:
|
||||
print(f"Error: {screen_text(str(folder))} {problem[1]}: --from names the folder "
|
||||
"to copy BIOS files from.", file=sys.stderr)
|
||||
for folder in getattr(args, "from") or []:
|
||||
refusal = from_folder_refusal(str(folder))
|
||||
if refusal is not None:
|
||||
for line in refusal.lines:
|
||||
print(line, file=sys.stderr)
|
||||
return None
|
||||
return tui_start(args, os_type)
|
||||
|
||||
|
||||
@@ -4964,7 +4964,7 @@ class OneEmulatorsFilesInOneCommand(unittest.TestCase):
|
||||
{"dest": "ibm.rom", "cores": None, "systems": ["ibm-pc"]},
|
||||
]
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
kept, _omitted = install._narrow_to_emulators(
|
||||
_chosen, kept, _omitted = install._narrow_to_emulators(
|
||||
["PCem"], self.MANIFEST, "retroarch", files, [])
|
||||
self.assertEqual(sorted(e["dest"] for e in kept), ["ibm.rom", "pcem/ibmpc.bin"])
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ class RealListParity(unittest.TestCase):
|
||||
str(REPO_ROOT / "bios"), tempfile.gettempdir(),
|
||||
standalone=True, zip_contents=self.zip_contents,
|
||||
offline=True, record=record)
|
||||
files, omitted = install._narrow_to_emulators(
|
||||
_chosen, files, omitted = install._narrow_to_emulators(
|
||||
[profile], full, plat, full["files"], full["omitted_files"])
|
||||
files, _omitted = install.standalone_layout(full, layouts, [profile],
|
||||
files, omitted)
|
||||
|
||||
@@ -768,7 +768,7 @@ class WhereTheSearchGoes(FromFolder):
|
||||
self.addCleanup(install.LOCAL.reset)
|
||||
with mock.patch.object(install, "MAX_SCANNED_FILES", 2), \
|
||||
contextlib.redirect_stdout(io.StringIO()) as text:
|
||||
install._open_from_folders([self.old])
|
||||
install.open_from_folders([self.old])
|
||||
self.assertIn(f"Read the first 2 files of {self.old} only", text.getvalue())
|
||||
self.assertEqual([json.loads(line) for line in out.getvalue().splitlines()], [{
|
||||
"event": "scanned", "folder": str(self.old), "files": 2, "truncated": True,
|
||||
|
||||
@@ -2110,7 +2110,7 @@ class CleanupSurvivesABrokenTerminal(unittest.TestCase):
|
||||
with mock.patch.object(install._TuiTerminal, "draw", breaking_draw), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
mock.patch.object(install, "tui_start", return_value=(fresh_state(), [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.object(sys, "stdin", tty), mock.patch.object(sys, "stdout", out), \
|
||||
mock.patch.object(sys, "stderr", out):
|
||||
@@ -2502,7 +2502,7 @@ class WorkFolders(unittest.TestCase):
|
||||
out = io.StringIO()
|
||||
with mock.patch.object(install, "_TuiTerminal", self.Terminal), \
|
||||
mock.patch.object(install, "tui_start", return_value=(state, [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
mock.patch.object(sys, "stdout", out), mock.patch.object(sys, "stderr", out):
|
||||
@@ -2542,7 +2542,7 @@ class WorkFolders(unittest.TestCase):
|
||||
with mock.patch.object(install.tempfile, "mkdtemp",
|
||||
side_effect=OSError(errno.ENOSPC, "No space left")), \
|
||||
mock.patch.object(install, "tui_start", return_value=(fresh_state(), [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.object(sys, "stderr", err):
|
||||
self.assertEqual(install.run_tui(_args()), 1)
|
||||
@@ -2578,7 +2578,7 @@ class WorkFolders(unittest.TestCase):
|
||||
mock.patch.object(self.Terminal, "enter",
|
||||
lambda _t, entered=entered: entered.append(True)), \
|
||||
mock.patch.object(install, "tui_start", side_effect=starting), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "_tui_fetch") as fetch, \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.object(sys, "stdout", out), \
|
||||
@@ -3449,7 +3449,7 @@ class IdleExit(unittest.TestCase):
|
||||
with mock.patch.object(install, "_TuiTerminal", Quiet), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
mock.patch.object(install, "tui_start", return_value=(state, [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.dict(os.environ, {install.TUI_IDLE_ENV: "0.05"}), \
|
||||
mock.patch.object(sys, "stdout", out), mock.patch.object(sys, "stderr", out):
|
||||
@@ -4640,7 +4640,7 @@ class Crash(unittest.TestCase):
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with mock.patch.object(install, "_TuiTerminal", self.FakeTerminal), \
|
||||
mock.patch.object(install, "tui_start", return_value=(fresh_state(), [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="linux"), \
|
||||
mock.patch.object(sys, "stdout", out), mock.patch.object(sys, "stderr", err):
|
||||
code = install.run_tui(args)
|
||||
@@ -5056,7 +5056,7 @@ class WindowsHasNoPosixModules(unittest.TestCase):
|
||||
mock.patch.object(install, "_drop_closed_terminal"), \
|
||||
mock.patch.object(install.tempfile, "mkdtemp", return_value=str(work)), \
|
||||
mock.patch.object(install, "tui_start", return_value=(fresh_state(), [])), \
|
||||
mock.patch.object(install, "_open_local_sources"), \
|
||||
mock.patch.object(install, "open_list_and_pack"), \
|
||||
mock.patch.object(install, "detect_os", return_value="windows"), \
|
||||
mock.patch.object(sys, "stdin", console), \
|
||||
mock.patch.object(sys, "stdout", console), \
|
||||
@@ -16417,7 +16417,7 @@ class EmulatorChoiceMatchesTheEmulatorPack(unittest.TestCase):
|
||||
args = install.build_parser().parse_args(argv[2:])
|
||||
self.assertEqual(args.emulator, [emulator])
|
||||
with contextlib.redirect_stdout(io.StringIO()):
|
||||
files, _omitted = install._narrow_to_emulators(
|
||||
_chosen, files, _omitted = install._narrow_to_emulators(
|
||||
args.emulator, manifest, plat, manifest["files"],
|
||||
manifest["omitted_files"])
|
||||
installed = {entry["dest"]: entry["sha1"] for entry in files}
|
||||
|
||||
Reference in new issue
Block a user