mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: count roms left out after the choice
The roms, configs and emulator folder lines were printed while the entries were placed, before --system, --core, --region and the menu narrowed the list: --system panasonic-3do on EmuDeck said 1918 roms files were left out where 6 belong to the run. Placement now only records the reason, and say_unplaced counts the narrowed entries next to say_saves. The unused printing branch of place_save_entries goes with it.
This commit is contained in:
1 parent
6e0b0724de
commit
571c4bbfd9
10 files changed
+130
-96
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 = "b5dd1137457019ae36cfff7bb22c32054865bd891353786ab5ab3566d9af5980"
|
||||
$defaultInstallSha256 = "7eb5c3718dc892a8cc773493724757cd2de45793475e96082a09fbb535aae769"
|
||||
# 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
|
||||
|
||||
+42
-32
@@ -6304,14 +6304,14 @@ def save_directory_for(
|
||||
|
||||
def place_save_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, override: Path | None,
|
||||
display: str, say: bool = True,
|
||||
display: str,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the save directory for the entries read below it.
|
||||
|
||||
Returns the files to install and, when the save directory is unknown,
|
||||
the entries left out as omissions, said once with the reason. Without
|
||||
say nothing is printed or sent: the run says it (say_saves) once a
|
||||
choice of systems has kept the files it counts.
|
||||
the entries left out as omissions. Nothing is printed or sent: the run
|
||||
says it (say_saves) once a choice of systems has kept the files it
|
||||
counts.
|
||||
"""
|
||||
saved = [entry for entry in files if entry.get("root") == "save"]
|
||||
if not saved:
|
||||
@@ -6327,15 +6327,8 @@ def place_save_entries(
|
||||
if place.by_core:
|
||||
where += f"{os.sep}<core>"
|
||||
_SAVE_WHERE[bios_path] = where
|
||||
if say:
|
||||
print(f" {saves_line(display, len(saved), where)}")
|
||||
EVENTS.emit("saves", platform=str(manifest.get("platform", "")),
|
||||
files=len(saved), folder=where)
|
||||
return files, []
|
||||
_SAVE_WHY[bios_path] = place
|
||||
if say:
|
||||
print(f" {_plural(len(saved), 'file')} read from {display}'s save directory "
|
||||
f"left out: {place}.")
|
||||
kept = [entry for entry in files if entry.get("root") != "save"]
|
||||
unplaced = [
|
||||
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
|
||||
@@ -6349,7 +6342,7 @@ def place_save_entries(
|
||||
|
||||
|
||||
def place_relative_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, display: str, say: bool = True,
|
||||
files: list[dict], bios_path: Path, manifest: dict,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the roms and configs folders for the entries read below them.
|
||||
|
||||
@@ -6357,7 +6350,8 @@ def place_relative_entries(
|
||||
source places them (ROCKNIX's /storage/roms holds bios/, Batocera's
|
||||
configs folder is ../system/configs): a BIOS folder of the platform's
|
||||
name puts the root there. Any other is a folder this run cannot relate
|
||||
to the root, and the entries are left out with the reason.
|
||||
to the root, and the entries are left out, the reason kept for
|
||||
say_unplaced.
|
||||
"""
|
||||
unplaced: list[dict] = []
|
||||
for root in RELATIVE_ROOTS:
|
||||
@@ -6372,9 +6366,8 @@ def place_relative_entries(
|
||||
if folder is not None:
|
||||
_RELATIVE_DIRS[(bios_path, root)] = folder
|
||||
continue
|
||||
if say:
|
||||
print(f" {_plural(len(below), 'file')} read from {display}'s {root} folder left "
|
||||
f"out: {bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder.")
|
||||
_UNPLACED_WHY[(bios_path, root)] = (
|
||||
f"{bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder")
|
||||
files = [entry for entry in files if entry.get("root") != root]
|
||||
unplaced += [
|
||||
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
|
||||
@@ -6386,7 +6379,7 @@ def place_relative_entries(
|
||||
|
||||
|
||||
def place_emulator_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, display: str, say: bool = True,
|
||||
files: list[dict], bios_path: Path, manifest: dict,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the emulator folder each entry a launcher runs from one goes to.
|
||||
|
||||
@@ -6394,9 +6387,9 @@ def place_emulator_entries(
|
||||
launcher config (RetroBat's bios beside emulationstation): a BIOS
|
||||
folder of that name whose parent holds the config is the platform's.
|
||||
A key the config sets moves the folder somewhere this run does not
|
||||
follow, so its files are left out. Otherwise the folder is the first of
|
||||
the searched places that exists, the default one when none does, as the
|
||||
launcher searches them.
|
||||
follow, so its files are left out, the reason kept for say_unplaced.
|
||||
Otherwise the folder is the first of the searched places that exists,
|
||||
the default one when none does, as the launcher searches them.
|
||||
"""
|
||||
inside = [entry for entry in files if entry.get("root") == "emulators"]
|
||||
if not inside:
|
||||
@@ -6441,15 +6434,32 @@ def place_emulator_entries(
|
||||
"reason": "no_emulators_directory", "cores": entry.get("cores"),
|
||||
"root": "emulators",
|
||||
})
|
||||
if unplaced and say:
|
||||
why = (f"{config} sets their folder" if matches
|
||||
else f"{bios_path} is not the {layout.get('bios_folder') or 'BIOS'} folder "
|
||||
f"beside {layout.get('config') or 'its config'}")
|
||||
print(f" {_plural(len(unplaced), 'file')} read from {display}'s emulator folders "
|
||||
f"left out: {why}.")
|
||||
if unplaced:
|
||||
_UNPLACED_WHY[(bios_path, "emulators")] = (
|
||||
f"{config} sets their folder" if matches
|
||||
else f"{bios_path} is not the {layout.get('bios_folder') or 'BIOS'} folder "
|
||||
f"beside {layout.get('config') or 'its config'}")
|
||||
return kept, unplaced
|
||||
|
||||
|
||||
# Per BIOS folder and root, why the files read below a roms, configs or
|
||||
# emulators folder are left out: said once a choice keeps the ones counted.
|
||||
_UNPLACED_WHY: dict[tuple[Path, str], str] = {}
|
||||
_UNPLACED_FOLDERS = {"roms": "roms folder", "configs": "configs folder",
|
||||
"emulators": "emulator folders"}
|
||||
|
||||
|
||||
def say_unplaced(omitted: list[dict], bios_path: Path, display: str) -> None:
|
||||
"""The roms, configs and emulator folder lines, over the entries a
|
||||
narrowed run still counts: --system panasonic-3do said 1918 files read
|
||||
from EmuDeck's roms folder were left out, 6 of them the 3DO's."""
|
||||
for root, folder in _UNPLACED_FOLDERS.items():
|
||||
left = sum(1 for entry in omitted if entry.get("reason") == f"no_{root}_directory")
|
||||
why = _UNPLACED_WHY.get((bios_path, root))
|
||||
if left and why is not None:
|
||||
print(f" {_plural(left, 'file')} read from {display}'s {folder} left out: {why}.")
|
||||
|
||||
|
||||
# Per BIOS folder, where its save files go in words, or why that is not
|
||||
# known: read by the lines that count them once a choice is made.
|
||||
_SAVE_WHERE: dict[Path, str] = {}
|
||||
@@ -22193,17 +22203,15 @@ def _pass_version_and_saves(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
|
||||
# Before the menu: it offered 23 files, then 22 were checked, the
|
||||
# one read from an unknown save directory left out. Said once the
|
||||
# choice is made, over the files it keeps (say_saves).
|
||||
# choice is made, over the files it keeps (say_saves, say_unplaced).
|
||||
p.display = display = display_name(plat_name, manifest)
|
||||
if not run.packing:
|
||||
# A pack keeps every root's files: the device installing it
|
||||
# places them.
|
||||
files, unplaced = place_save_entries(
|
||||
p.files, bios_path, manifest, run.args.save_dir, display, say=False)
|
||||
files, beyond = place_relative_entries(
|
||||
files, bios_path, manifest, display, say=not run.listing)
|
||||
p.files, elsewhere = place_emulator_entries(
|
||||
files, bios_path, manifest, display, say=not run.listing)
|
||||
p.files, bios_path, manifest, run.args.save_dir, display)
|
||||
files, beyond = place_relative_entries(files, bios_path, manifest)
|
||||
p.files, elsewhere = place_emulator_entries(files, bios_path, manifest)
|
||||
p.unplaced = [*unplaced, *beyond, *elsewhere]
|
||||
if not manifest.get("save_directory") and not run.packing:
|
||||
# Its own list leaves these files out: naming the folder with
|
||||
@@ -22433,6 +22441,8 @@ def _pass_unplaced(run: _InstallRun, p: _PlatformPass) -> bool:
|
||||
if not run.packing:
|
||||
say_saves(p.plat_name, p.files, p.omitted_files + p.unplaced, p.bios_path, p.display,
|
||||
p.menu)
|
||||
if not run.listing:
|
||||
say_unplaced(p.unplaced, p.bios_path, p.display)
|
||||
|
||||
if args.list_systems or args.list_cores:
|
||||
_print_choices(p.plat_name, p.files, p.omitted_files, args.list_systems, p.manifest)
|
||||
|
||||
+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="b5dd1137457019ae36cfff7bb22c32054865bd891353786ab5ab3566d9af5980"
|
||||
DEFAULT_INSTALL_SHA256="7eb5c3718dc892a8cc773493724757cd2de45793475e96082a09fbb535aae769"
|
||||
# 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": 1470260,
|
||||
"sha256": "b5dd1137457019ae36cfff7bb22c32054865bd891353786ab5ab3566d9af5980",
|
||||
"size": 1470376,
|
||||
"sha256": "7eb5c3718dc892a8cc773493724757cd2de45793475e96082a09fbb535aae769",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1523885,
|
||||
"sha256": "d79004b77c356c6493576608f7265590abdb25e9c823427676b9a492e5885e01"
|
||||
"size": 1524001,
|
||||
"sha256": "a6e6da27de83262e39da7e4b5128cfdfcf046ac3d054c9e878ab9be51f0929c5"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1470260,
|
||||
"sha256": "b5dd1137457019ae36cfff7bb22c32054865bd891353786ab5ab3566d9af5980",
|
||||
"size": 1470376,
|
||||
"sha256": "7eb5c3718dc892a8cc773493724757cd2de45793475e96082a09fbb535aae769",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1470260,
|
||||
"sha256": "b5dd1137457019ae36cfff7bb22c32054865bd891353786ab5ab3566d9af5980",
|
||||
"size": 1470376,
|
||||
"sha256": "7eb5c3718dc892a8cc773493724757cd2de45793475e96082a09fbb535aae769",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
@@ -152,14 +152,14 @@ def save_directory_for(
|
||||
|
||||
def place_save_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, override: Path | None,
|
||||
display: str, say: bool = True,
|
||||
display: str,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the save directory for the entries read below it.
|
||||
|
||||
Returns the files to install and, when the save directory is unknown,
|
||||
the entries left out as omissions, said once with the reason. Without
|
||||
say nothing is printed or sent: the run says it (say_saves) once a
|
||||
choice of systems has kept the files it counts.
|
||||
the entries left out as omissions. Nothing is printed or sent: the run
|
||||
says it (say_saves) once a choice of systems has kept the files it
|
||||
counts.
|
||||
"""
|
||||
saved = [entry for entry in files if entry.get("root") == "save"]
|
||||
if not saved:
|
||||
@@ -175,15 +175,8 @@ def place_save_entries(
|
||||
if place.by_core:
|
||||
where += f"{os.sep}<core>"
|
||||
_SAVE_WHERE[bios_path] = where
|
||||
if say:
|
||||
print(f" {saves_line(display, len(saved), where)}")
|
||||
EVENTS.emit("saves", platform=str(manifest.get("platform", "")),
|
||||
files=len(saved), folder=where)
|
||||
return files, []
|
||||
_SAVE_WHY[bios_path] = place
|
||||
if say:
|
||||
print(f" {_plural(len(saved), 'file')} read from {display}'s save directory "
|
||||
f"left out: {place}.")
|
||||
kept = [entry for entry in files if entry.get("root") != "save"]
|
||||
unplaced = [
|
||||
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
|
||||
@@ -197,7 +190,7 @@ def place_save_entries(
|
||||
|
||||
|
||||
def place_relative_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, display: str, say: bool = True,
|
||||
files: list[dict], bios_path: Path, manifest: dict,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the roms and configs folders for the entries read below them.
|
||||
|
||||
@@ -205,7 +198,8 @@ def place_relative_entries(
|
||||
source places them (ROCKNIX's /storage/roms holds bios/, Batocera's
|
||||
configs folder is ../system/configs): a BIOS folder of the platform's
|
||||
name puts the root there. Any other is a folder this run cannot relate
|
||||
to the root, and the entries are left out with the reason.
|
||||
to the root, and the entries are left out, the reason kept for
|
||||
say_unplaced.
|
||||
"""
|
||||
unplaced: list[dict] = []
|
||||
for root in RELATIVE_ROOTS:
|
||||
@@ -220,9 +214,8 @@ def place_relative_entries(
|
||||
if folder is not None:
|
||||
_RELATIVE_DIRS[(bios_path, root)] = folder
|
||||
continue
|
||||
if say:
|
||||
print(f" {_plural(len(below), 'file')} read from {display}'s {root} folder left "
|
||||
f"out: {bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder.")
|
||||
_UNPLACED_WHY[(bios_path, root)] = (
|
||||
f"{bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder")
|
||||
files = [entry for entry in files if entry.get("root") != root]
|
||||
unplaced += [
|
||||
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
|
||||
@@ -234,7 +227,7 @@ def place_relative_entries(
|
||||
|
||||
|
||||
def place_emulator_entries(
|
||||
files: list[dict], bios_path: Path, manifest: dict, display: str, say: bool = True,
|
||||
files: list[dict], bios_path: Path, manifest: dict,
|
||||
) -> tuple[list[dict], list[dict]]:
|
||||
"""Find the emulator folder each entry a launcher runs from one goes to.
|
||||
|
||||
@@ -242,9 +235,9 @@ def place_emulator_entries(
|
||||
launcher config (RetroBat's bios beside emulationstation): a BIOS
|
||||
folder of that name whose parent holds the config is the platform's.
|
||||
A key the config sets moves the folder somewhere this run does not
|
||||
follow, so its files are left out. Otherwise the folder is the first of
|
||||
the searched places that exists, the default one when none does, as the
|
||||
launcher searches them.
|
||||
follow, so its files are left out, the reason kept for say_unplaced.
|
||||
Otherwise the folder is the first of the searched places that exists,
|
||||
the default one when none does, as the launcher searches them.
|
||||
"""
|
||||
inside = [entry for entry in files if entry.get("root") == "emulators"]
|
||||
if not inside:
|
||||
@@ -289,15 +282,32 @@ def place_emulator_entries(
|
||||
"reason": "no_emulators_directory", "cores": entry.get("cores"),
|
||||
"root": "emulators",
|
||||
})
|
||||
if unplaced and say:
|
||||
why = (f"{config} sets their folder" if matches
|
||||
else f"{bios_path} is not the {layout.get('bios_folder') or 'BIOS'} folder "
|
||||
f"beside {layout.get('config') or 'its config'}")
|
||||
print(f" {_plural(len(unplaced), 'file')} read from {display}'s emulator folders "
|
||||
f"left out: {why}.")
|
||||
if unplaced:
|
||||
_UNPLACED_WHY[(bios_path, "emulators")] = (
|
||||
f"{config} sets their folder" if matches
|
||||
else f"{bios_path} is not the {layout.get('bios_folder') or 'BIOS'} folder "
|
||||
f"beside {layout.get('config') or 'its config'}")
|
||||
return kept, unplaced
|
||||
|
||||
|
||||
# Per BIOS folder and root, why the files read below a roms, configs or
|
||||
# emulators folder are left out: said once a choice keeps the ones counted.
|
||||
_UNPLACED_WHY: dict[tuple[Path, str], str] = {}
|
||||
_UNPLACED_FOLDERS = {"roms": "roms folder", "configs": "configs folder",
|
||||
"emulators": "emulator folders"}
|
||||
|
||||
|
||||
def say_unplaced(omitted: list[dict], bios_path: Path, display: str) -> None:
|
||||
"""The roms, configs and emulator folder lines, over the entries a
|
||||
narrowed run still counts: --system panasonic-3do said 1918 files read
|
||||
from EmuDeck's roms folder were left out, 6 of them the 3DO's."""
|
||||
for root, folder in _UNPLACED_FOLDERS.items():
|
||||
left = sum(1 for entry in omitted if entry.get("reason") == f"no_{root}_directory")
|
||||
why = _UNPLACED_WHY.get((bios_path, root))
|
||||
if left and why is not None:
|
||||
print(f" {_plural(left, 'file')} read from {display}'s {folder} left out: {why}.")
|
||||
|
||||
|
||||
# Per BIOS folder, where its save files go in words, or why that is not
|
||||
# known: read by the lines that count them once a choice is made.
|
||||
_SAVE_WHERE: dict[Path, str] = {}
|
||||
|
||||
@@ -43,6 +43,7 @@ from installer.frontend_folders import (
|
||||
place_relative_entries,
|
||||
place_save_entries,
|
||||
say_saves,
|
||||
say_unplaced,
|
||||
)
|
||||
from installer.games import fallback_lines, read_games
|
||||
from installer.install_record import _RECORD_TAKEN, by_record, drop_recorded, record_menu_words
|
||||
@@ -490,17 +491,15 @@ def _pass_version_and_saves(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
|
||||
# Before the menu: it offered 23 files, then 22 were checked, the
|
||||
# one read from an unknown save directory left out. Said once the
|
||||
# choice is made, over the files it keeps (say_saves).
|
||||
# choice is made, over the files it keeps (say_saves, say_unplaced).
|
||||
p.display = display = display_name(plat_name, manifest)
|
||||
if not run.packing:
|
||||
# A pack keeps every root's files: the device installing it
|
||||
# places them.
|
||||
files, unplaced = place_save_entries(
|
||||
p.files, bios_path, manifest, run.args.save_dir, display, say=False)
|
||||
files, beyond = place_relative_entries(
|
||||
files, bios_path, manifest, display, say=not run.listing)
|
||||
p.files, elsewhere = place_emulator_entries(
|
||||
files, bios_path, manifest, display, say=not run.listing)
|
||||
p.files, bios_path, manifest, run.args.save_dir, display)
|
||||
files, beyond = place_relative_entries(files, bios_path, manifest)
|
||||
p.files, elsewhere = place_emulator_entries(files, bios_path, manifest)
|
||||
p.unplaced = [*unplaced, *beyond, *elsewhere]
|
||||
if not manifest.get("save_directory") and not run.packing:
|
||||
# Its own list leaves these files out: naming the folder with
|
||||
@@ -730,6 +729,8 @@ def _pass_unplaced(run: _InstallRun, p: _PlatformPass) -> bool:
|
||||
if not run.packing:
|
||||
say_saves(p.plat_name, p.files, p.omitted_files + p.unplaced, p.bios_path, p.display,
|
||||
p.menu)
|
||||
if not run.listing:
|
||||
say_unplaced(p.unplaced, p.bios_path, p.display)
|
||||
|
||||
if args.list_systems or args.list_cores:
|
||||
_print_choices(p.plat_name, p.files, p.omitted_files, args.list_systems, p.manifest)
|
||||
|
||||
+17
-5
@@ -1332,9 +1332,23 @@ class OuterRootsAreUntrusted(unittest.TestCase):
|
||||
|
||||
def test_a_list_without_a_roms_root_leaves_the_files_out(self):
|
||||
files = [{"dest": "pico-8/pico8_64", "root": "roms", "cores": ["x"]}]
|
||||
kept, left = install.place_relative_entries(files, Path("/card/roms/bios"), {}, "x", say=False)
|
||||
kept, left = install.place_relative_entries(files, Path("/card/roms/bios"), {})
|
||||
self.assertEqual((kept, [o["reason"] for o in left]), ([], ["no_roms_directory"]))
|
||||
|
||||
def test_roms_left_out_are_counted_after_the_choice(self):
|
||||
# --system panasonic-3do said 1918 EmuDeck roms files were left out, 6 of them its.
|
||||
files = [{"dest": f"{system}/x{n}.bin", "root": "roms", "systems": [system]}
|
||||
for system, count in (("panasonic-3do", 1), ("sony-psx", 3)) for n in range(count)]
|
||||
bios = Path("/card/notbios")
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
kept, left = install.place_relative_entries(files, bios, {})
|
||||
self.assertEqual((kept, len(left), out.getvalue()), ([], 4, ""))
|
||||
chosen = install.narrow([], left, ["panasonic-3do"], [], [])[1]
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
install.say_unplaced(chosen, bios, "EmuDeck")
|
||||
self.assertEqual(out.getvalue(), " 1 file read from EmuDeck's roms folder left out: "
|
||||
f"{bios} is not its BIOS folder.\n")
|
||||
|
||||
def test_unsafe_emulator_folders_are_refused(self):
|
||||
for field in ("searched", "default", "config"):
|
||||
for value in self.UNSAFE + ("../{key}", "/abs/{key}"):
|
||||
@@ -1387,11 +1401,9 @@ class OuterRootsAreUntrusted(unittest.TestCase):
|
||||
for dest in ("../x/prog", "C:/prog", "prog\\..\\..\\x/a"):
|
||||
with self.subTest(dest=dest), self.assertRaises(ValueError):
|
||||
install.place_emulator_entries(
|
||||
[{"dest": dest, "root": "emulators"}], home / "bios", manifest, "x",
|
||||
say=False)
|
||||
[{"dest": dest, "root": "emulators"}], home / "bios", manifest)
|
||||
kept, left = install.place_emulator_entries(
|
||||
[{"dest": "prog/prog.exe", "root": "emulators"}], home / "bios", manifest, "x",
|
||||
say=False)
|
||||
[{"dest": "prog/prog.exe", "root": "emulators"}], home / "bios", manifest)
|
||||
self.assertEqual((len(kept), left), (1, []))
|
||||
folder, rest = install._entry_place(home / "bios", kept[0])
|
||||
self.assertEqual((folder, rest), (home / "emulators" / "prog", "prog.exe"))
|
||||
|
||||
@@ -4520,7 +4520,8 @@ class LineModeOffline(unittest.TestCase):
|
||||
place = install.SavePlace(Path("/saves"), False)
|
||||
with mock.patch.object(install, "save_directory_for", return_value=place), \
|
||||
contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
install.place_save_entries(files, Path("/bios"), {}, None, "RetroArch")
|
||||
kept, left = install.place_save_entries(files, Path("/bios"), {}, None, "RetroArch")
|
||||
install.say_saves("retroarch", kept, left, Path("/bios"), "RetroArch", False)
|
||||
self.assertIn("1 file read from RetroArch's save directory goes to /saves",
|
||||
out.getvalue())
|
||||
|
||||
@@ -9996,14 +9997,14 @@ class CardFoldersAndNarrowBars(unittest.TestCase):
|
||||
|
||||
def test_a_save_directory_left_out_has_one_wording(self):
|
||||
files = [{"dest": "keys.txt", "root": "save", "sha1": "0" * 40, "size": 1}]
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
install.place_save_entries(files, self.root / "BIOS",
|
||||
{"platform": "retroarch", "save_directory": {
|
||||
"folder": "saves", "by_core": False},
|
||||
"base_destination": "system"},
|
||||
None, "RetroArch")
|
||||
kept, left = install.place_save_entries(files, self.root / "BIOS",
|
||||
{"platform": "retroarch", "save_directory": {
|
||||
"folder": "saves", "by_core": False},
|
||||
"base_destination": "system"},
|
||||
None, "RetroArch")
|
||||
self.assertIn("left out: its place is not known. Name it with --save-dir.",
|
||||
out.getvalue())
|
||||
"\n".join(install.save_lines(kept, left, self.root / "BIOS",
|
||||
"RetroArch")))
|
||||
|
||||
|
||||
class CardBoundaries(unittest.TestCase):
|
||||
|
||||
@@ -346,13 +346,13 @@ class AUserFolderInTheConfigsFolder(unittest.TestCase):
|
||||
install._check_relative_directories(manifest)
|
||||
files = [{"dest": "shadps4/user/sys_modules/libSceNgs2.sprx", "root": "configs"}]
|
||||
bios = Path("/userdata/bios")
|
||||
kept, left = install.place_relative_entries(files, bios, manifest, "x", say=False)
|
||||
kept, left = install.place_relative_entries(files, bios, manifest)
|
||||
self.assertEqual((len(kept), left), (1, []))
|
||||
self.assertEqual(
|
||||
install._entry_place(bios, kept[0])[0], Path("/userdata/system/configs")
|
||||
)
|
||||
kept, left = install.place_relative_entries(
|
||||
files, Path("/elsewhere/firmware"), manifest, "x", say=False)
|
||||
files, Path("/elsewhere/firmware"), manifest)
|
||||
self.assertEqual((kept, [o["reason"] for o in left]), ([], ["no_configs_directory"]))
|
||||
for value in ("../C:x", "../../../x", "../system/../x"):
|
||||
with self.subTest(from_bios=value), self.assertRaises(ValueError):
|
||||
|
||||
@@ -456,7 +456,7 @@ class AProgramRunFromItsFolder(unittest.TestCase):
|
||||
install._check_relative_directories(manifest)
|
||||
files = list(manifest["files"])
|
||||
card = self.root / "card" / "roms" / "bios"
|
||||
kept, left = install.place_relative_entries(files, card, manifest, "romsplat", say=False)
|
||||
kept, left = install.place_relative_entries(files, card, manifest)
|
||||
self.assertEqual((len(kept), left), (2, []))
|
||||
self.assertEqual(
|
||||
install._entry_path(card, kept[0]),
|
||||
@@ -464,7 +464,7 @@ class AProgramRunFromItsFolder(unittest.TestCase):
|
||||
if install._entry_path(card, kept[0]).is_absolute() else card.parent / kept[0]["dest"],
|
||||
)
|
||||
other = self.root / "elsewhere"
|
||||
kept, left = install.place_relative_entries(files, other, manifest, "romsplat", say=False)
|
||||
kept, left = install.place_relative_entries(files, other, manifest)
|
||||
self.assertEqual(kept, [])
|
||||
self.assertEqual({o["reason"] for o in left}, {"no_roms_directory"})
|
||||
with self.assertRaises(ValueError):
|
||||
@@ -473,7 +473,7 @@ class AProgramRunFromItsFolder(unittest.TestCase):
|
||||
beside = {**manifest, "roms_directory": {"bios_folder": "bios", "from_bios": "../roms"}}
|
||||
install._check_relative_directories(beside)
|
||||
disk = self.root / "userdata" / "bios"
|
||||
install.place_relative_entries(files, disk, beside, "romsplat", say=False)
|
||||
install.place_relative_entries(files, disk, beside)
|
||||
self.assertEqual(install._entry_place(disk, kept_entry := files[0])[0],
|
||||
self.root / "userdata" / "roms")
|
||||
self.assertEqual(kept_entry["root"], "roms")
|
||||
@@ -503,21 +503,21 @@ class AProgramRunFromItsFolder(unittest.TestCase):
|
||||
bios = home / "bios"
|
||||
bios.mkdir(parents=True)
|
||||
# Not the platform's folder: no launcher config beside it.
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest, "emuplat", say=False)
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest)
|
||||
self.assertEqual((kept, {o["reason"] for o in left}), ([], {"no_emulators_directory"}))
|
||||
(home / "frontend").mkdir()
|
||||
(home / "frontend" / "launcher.cfg").write_text("other=x\n")
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest, "emuplat", say=False)
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest)
|
||||
self.assertEqual((len(kept), left), (2, []))
|
||||
entry = next(f for f in kept if f["dest"] == "prog/prog")
|
||||
self.assertEqual(install._entry_place(bios, entry), (home / "emulators" / "prog", "prog"))
|
||||
# The first searched place that exists wins.
|
||||
(home / "frontend" / "prog").mkdir()
|
||||
install.place_emulator_entries(files, bios, manifest, "emuplat", say=False)
|
||||
install.place_emulator_entries(files, bios, manifest)
|
||||
self.assertEqual(install._entry_place(bios, entry)[0], home / "frontend" / "prog")
|
||||
# A key the launcher config sets moves the folder: left out.
|
||||
(home / "frontend" / "launcher.cfg").write_text("prog=D:\\Prog\n")
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest, "emuplat", say=False)
|
||||
kept, left = install.place_emulator_entries(files, bios, manifest)
|
||||
self.assertEqual((kept, len(left)), ([], 2))
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user