fix: a left-out folder carries its reason

This commit is contained in:
Abdessamad Derraz committed 2026-11-24 03:39:00 +01:00
1 parent e7b9acb425
commit dec7d4bc05
19 files changed
+324 -130

No files matched your search

+1 -1
View File
@@ -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 = "a65844ce190649e5c0666f3de835030f85b97d68dd7a3801a506ff0bbd813630"
$defaultInstallSha256 = "8f0f6c89137204a0616984f4d083786e2f23a66b48cb3446a77712d92ebeba17"
# 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
+122 -56
View File
@@ -1644,6 +1644,11 @@ EVENT_KEYS: dict[str, tuple[str, ...]] = {
# per core), once that directory is known. Not written when it is not:
# the summary's skipped then counts them (no_save_directory).
"saves": ("platform", "files", "folder"),
# Where saves is written, once per root (save, roms, configs or emulators)
# whose folder the run cannot place: why its files are left out, in
# words. The summary's skipped counts them (no_<root>_directory). A
# kind of its own, since schema 1 never adds a key to summary.
"unplaced": ("platform", "root", "why"),
"download": ("platform", "files", "bytes"),
"progress": ("files_done", "files_total", "bytes_done", "bytes_total"),
# Right after each progress event, and once when the files of a
@@ -6421,9 +6426,25 @@ def _retroarch_config_at(bios_path: Path) -> tuple[Path, Path] | None:
return None
# Why a save directory cannot be told, where nothing more is known.
SAVE_NOT_KNOWN = "its place is not known"
class SaveUnknown(NamedTuple):
"""Why this run cannot tell the save directory: the cause, and the
remedy line mode joins to it."""
cause: str
remedy: str = ""
@property
def words(self) -> str:
return f"{self.cause}{self.remedy}"
def save_directory_for(
bios_path: Path, manifest: dict, override: Path | None = None,
) -> SavePlace | str:
) -> SavePlace | SaveUnknown:
"""The save directory the platform's frontend hands its cores, or why
this run cannot tell.
@@ -6443,7 +6464,7 @@ def save_directory_for(
"""
layout = manifest.get("save_directory")
if not layout:
return "the file list names no save directory for this platform"
return SaveUnknown("the file list names no save directory for this platform")
folder = layout["folder"]
listed = bool(layout["by_core"])
by_core = listed
@@ -6452,8 +6473,8 @@ def save_directory_for(
cfg_path, app_dir = found
for key in ("savefiles_in_content_dir", "sort_savefiles_by_content_enable"):
if _cfg_true(_retroarch_cfg_value(cfg_path, key)):
return (f"RetroArch keeps saves beside each game ({key} in {cfg_path}): "
"name the folder with --save-dir")
return SaveUnknown(f"RetroArch keeps saves beside each game ({key} in "
f"{cfg_path})", ": name the folder with --save-dir")
sort = _retroarch_cfg_value(cfg_path, "sort_savefiles_enable")
if sort is not None:
by_core = _cfg_true(sort)
@@ -6474,7 +6495,7 @@ def save_directory_for(
return SavePlace(bios_path / folder, by_core, listed)
# The wording of the run's end, said before the menu too: two wordings
# of one fact in one run, the first printing /mnt/e under WSL.
return "its place is not known. Name it with --save-dir"
return SaveUnknown(SAVE_NOT_KNOWN, ". Name it with --save-dir")
def place_save_entries(
@@ -6484,9 +6505,9 @@ def place_save_entries(
"""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. 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, each with why (the cause) and the
remedy line mode joins to it. 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:
@@ -6503,13 +6524,13 @@ def place_save_entries(
where += f"{os.sep}<core>"
_SAVE_WHERE[bios_path] = where
return files, []
_SAVE_WHY[bios_path] = place
kept = [entry for entry in files if entry.get("root") != "save"]
unplaced = [
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": "no_save_directory", "frontend": display,
"cores": entry.get("cores"), "root": "save",
"cores": entry.get("cores"), "root": "save", "why": place.cause,
"remedy": place.remedy,
**({"core_folder": entry["core_folder"]} if entry.get("core_folder") else {})}
for entry in saved
]
@@ -6525,8 +6546,7 @@ 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, the reason kept for
say_unplaced.
to the root, and the entries are left out, each with why in words.
"""
unplaced: list[dict] = []
for root in RELATIVE_ROOTS:
@@ -6541,13 +6561,13 @@ def place_relative_entries(
if folder is not None:
_RELATIVE_DIRS[(bios_path, root)] = folder
continue
_UNPLACED_WHY[(bios_path, root)] = (
f"{bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder")
why = 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,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": f"no_{root}_directory", "cores": entry.get("cores"), "root": root}
"reason": f"no_{root}_directory", "cores": entry.get("cores"), "root": root,
"why": why}
for entry in below
]
return files, unplaced
@@ -6562,7 +6582,7 @@ 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, the reason kept for say_unplaced.
follow, so its files are left out, each with why in words.
Otherwise the folder is the first of the searched places that exists,
the default one when none does, as the launcher searches them.
"""
@@ -6581,6 +6601,9 @@ def place_emulator_entries(
matches = True
else:
moved, matches = set(), False
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'}")
kept: list[dict] = []
unplaced: list[dict] = []
for entry in files:
@@ -6607,38 +6630,46 @@ def place_emulator_entries(
"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": "no_emulators_directory", "cores": entry.get("cores"),
"root": "emulators",
"root": "emulators", "why": 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"}
UNPLACED_FOLDERS = {"roms": "roms folder", "configs": "configs folder",
"emulators": "emulator folders"}
def say_unplaced(omitted: list[dict], bios_path: Path, display: str) -> None:
def unplaced_whys(omitted: list[dict]) -> dict[str, str]:
"""Per root (save, roms, configs, emulators), why the files read below
its folder are left out, as the entries carry it."""
whys: dict[str, str] = {}
for entry in omitted:
reason = str(entry.get("reason") or "")
if entry.get("why") and reason.startswith("no_") and reason.endswith("_directory"):
whys.setdefault(reason[3:-len("_directory")], str(entry["why"]))
return whys
def unplaced_line(display: str, root: str, count: int, why: str) -> str:
"""The files read from a roms, configs or emulator folder left out, and why."""
return (f"{_plural(count, 'file')} read from {display}'s {UNPLACED_FOLDERS[root]} "
f"left out: {why}.")
def say_unplaced(omitted: list[dict], 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():
whys = unplaced_whys(omitted)
for root in UNPLACED_FOLDERS:
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}.")
if left and root in whys:
print(f" {unplaced_line(display, root, left, whys[root])}")
# 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.
# Per BIOS folder, where its save files go in words: read by the lines that
# count them once a choice is made.
_SAVE_WHERE: dict[Path, str] = {}
_SAVE_WHY: dict[Path, str] = {}
def say_saves(plat: str, files: list[dict], omitted: list[dict], bios_path: Path,
@@ -6687,10 +6718,10 @@ def saves_line(display: str, count: int, where: str) -> str:
f"{shown_path(folder)}")
def unplaced_line(display: str, count: int, remedy: str) -> str:
def unplaced_save_line(display: str, count: int, remedy: str) -> str:
"""The files read from an unknown save directory, left out."""
return (f"{_plural(count, 'file')} read from {display}'s save directory left out: "
f"its place is not known. {remedy}")
f"{SAVE_NOT_KNOWN}. {remedy}")
def save_lines(files: list[dict], omitted: list[dict], bios_path: Path | None,
@@ -6704,12 +6735,12 @@ def save_lines(files: list[dict], omitted: list[dict], bios_path: Path | None,
where = _SAVE_WHERE.get(bios_path) if bios_path is not None else None
if count and where is not None:
lines.append(saves_line(display, count, where))
left = sum(1 for entry in omitted if entry.get("reason") == "no_save_directory")
left = [entry for entry in omitted if entry.get("reason") == "no_save_directory"]
if left:
why = _SAVE_WHY.get(bios_path) if bios_path is not None else None
lines.append(f"{_plural(left, 'file')} read from {display}'s save directory left "
f"out: {why}." if why else
unplaced_line(display, left, "Name it with --save-dir."))
why = next((entry for entry in left if entry.get("why")), None)
lines.append(f"{_plural(len(left), 'file')} read from {display}'s save directory "
f"left out: {why['why']}{why.get('remedy') or ''}." if why else
unplaced_save_line(display, len(left), "Name it with --save-dir."))
return lines
@@ -14327,7 +14358,7 @@ def _short_path(path: Path | None, home: Path) -> str:
# What a check run tells the screen, kept whole when Choose systems widens a
# --system plan: Back with the same ticks gives that plan back.
_CHECK_FIELDS = ("check", "files", "systems", "choices", "set_aside", "found", "scanned",
"unreadable", "saves", "check_summary", "checked_flags", "cli_systems",
"unreadable", "saves", "unplaced_why", "check_summary", "checked_flags", "cli_systems",
"facts", "ticked", "version", "board", "checked_dests", "games",
"games_unavailable")
@@ -14558,6 +14589,9 @@ class TuiState:
self.check_summary: dict | None = None
# The saves event of the check: the files that go to the save folder.
self.saves: dict | None = None
# The unplaced events of the check: per root (save, roms, configs,
# emulators), why the files read below its folder are left out.
self.unplaced_why: dict[str, str] = {}
# The version event of the check: the list built for another
# release than the one this machine runs, said on the plan and the
# result as line mode says it.
@@ -22754,7 +22788,17 @@ def _pass_version_and_saves(run: _InstallRun, p: _PlatformPass) -> None:
if not manifest.get("save_directory") and not run.packing:
# Its own list leaves these files out: naming the folder with
# --save-dir installs none of them, and was advised in a loop.
_SAVE_WHY[bios_path] = unlisted_saves_words(display)
why = unlisted_saves_words(display)
p.unplaced = [_unlisted_save(entry, why) for entry in p.unplaced]
p.omitted_files = [_unlisted_save(entry, why) for entry in p.omitted_files]
def _unlisted_save(entry: dict, why: str) -> dict:
"""entry, when read from a save directory the list names no place for,
with why in words and no remedy."""
if entry.get("reason") != "no_save_directory":
return entry
return {**entry, "why": why, "remedy": ""}
def _pass_games(run: _InstallRun, p: _PlatformPass) -> None:
@@ -22980,7 +23024,9 @@ def _pass_unplaced(run: _InstallRun, p: _PlatformPass) -> bool:
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)
say_unplaced(p.unplaced, p.display)
for root, why in unplaced_whys(p.omitted_files + p.unplaced).items():
EVENTS.emit("unplaced", platform=p.plat_name, root=root, why=why)
if args.list_systems or args.list_cores:
_print_choices(p.plat_name, p.files, p.omitted_files, args.list_systems, p.manifest)
@@ -25317,11 +25363,16 @@ def _save_folder_words(state: TuiState) -> str:
return _short_path(given, state.home)
if state.saves and state.saves.get("folder"):
return _short_path(Path(save_where_words(state.saves["folder"])[1]), state.home)
place = (save_directory_for(state.dest, state.manifest, None)
if state.dest is not None and state.manifest else None)
if isinstance(place, SavePlace):
return _short_path(spelled(place.directory), state.home)
return "not known"
# The cause the check gave, else the one the same rule gives here: a
# RetroArch keeping saves beside each game read as "not known".
why = state.unplaced_why.get("save")
if why is None:
place = (save_directory_for(state.dest, state.manifest, None)
if state.dest is not None and state.manifest else None)
if isinstance(place, SavePlace):
return _short_path(spelled(place.directory), state.home)
why = place.cause if place is not None else ""
return why if why and why != SAVE_NOT_KNOWN else "not known"
def _tui_card_bound(state: TuiState) -> tuple[str, str] | None:
@@ -27472,17 +27523,29 @@ def _saves_lines(state: TuiState, saves: dict | None, whole: bool = False) -> li
def _unplaced_lines(summary: dict | None, state: TuiState,
remedy: str = "") -> list[str]:
"""The files read from the frontend's save directory that the run left
out, that directory being unknown: said, never silent."""
count = sum(group.get("files", 0) for group in (summary or {}).get("skipped") or []
if group.get("reason") == "no_save_directory")
"""The files the run left out, their folder (save, roms, configs,
emulators) being unknown, with the reason line mode gives: said, never
silent."""
counts = {group.get("reason"): group.get("files", 0)
for group in (summary or {}).get("skipped") or []}
name = display_name(state.platform) if state.platform else "the frontend"
lines = _unplaced_save_lines(counts.get("no_save_directory", 0), name, state, remedy)
for root in UNPLACED_FOLDERS:
count, why = counts.get(f"no_{root}_directory", 0), state.unplaced_why.get(root)
if count and why:
lines.append(unplaced_line(name, root, count, why))
return lines
def _unplaced_save_lines(count: int, name: str, state: TuiState, remedy: str) -> list[str]:
"""The files read from the frontend's save directory left out, and why."""
if not count:
return []
name = display_name(state.platform) if state.platform else "the frontend"
left = f"{_plural(count, 'file')} read from {name}'s save directory left out"
if state.manifest and not state.manifest.get("save_directory"):
return [f"{left}.", _detail(f"{unlisted_saves_words(name)}.")]
return [f"{left}. {remedy or TUI_SAVE_REMEDY}", _detail("Its place is not known.")]
why = state.unplaced_why.get("save") or SAVE_NOT_KNOWN
return [f"{left}. {remedy or TUI_SAVE_REMEDY}", _detail(f"{why[:1].upper()}{why[1:]}.")]
# Said when ES-DE is found, and in fewer words where the long form would
@@ -29447,6 +29510,7 @@ def _start_run(state: TuiState, run: str) -> list[tuple]:
state.choices = state.set_aside = None
state.found, state.scanned, state.unreadable = [], [], []
state.check_summary = state.saves = None
state.unplaced_why = {}
state.version = state.version_short = state.board = ""
state.games = state.games_reading = state.games_unavailable = None
state.checked_flags = tui_flags(state)
@@ -31410,6 +31474,8 @@ def _take_check_event(state: TuiState, kind: str | None, event: dict) -> None:
f"{event['installed_version']}.")
elif kind == "saves":
state.saves = event
elif kind == "unplaced":
state.unplaced_why[str(event["root"])] = str(event["why"])
elif kind == "data" and state.check is not None:
state.check["data_bytes"] = event["bytes"]
elif kind == "space" and state.check is not None:
+1 -1
View File
@@ -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="a65844ce190649e5c0666f3de835030f85b97d68dd7a3801a506ff0bbd813630"
DEFAULT_INSTALL_SHA256="8f0f6c89137204a0616984f4d083786e2f23a66b48cb3446a77712d92ebeba17"
# 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
+8 -8
View File
@@ -27,8 +27,8 @@
{
"dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py",
"size": 1498299,
"sha256": "a65844ce190649e5c0666f3de835030f85b97d68dd7a3801a506ff0bbd813630",
"size": 1501295,
"sha256": "8f0f6c89137204a0616984f4d083786e2f23a66b48cb3446a77712d92ebeba17",
"executable": false
},
{
@@ -71,8 +71,8 @@
"muos": {
"archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1551924,
"sha256": "a9e926aa27131e295742b8742e8f50d41841e36d1e6a6cab883d41c4f420083b"
"size": 1554920,
"sha256": "c2f3297e7cb95e6d8d109a4c519fb036f2053ce48bac6b33173743cf0e5f5f61"
},
"members": [
{
@@ -92,8 +92,8 @@
{
"name": "RetroBIOS/install.py",
"repo_path": "install.py",
"size": 1498299,
"sha256": "a65844ce190649e5c0666f3de835030f85b97d68dd7a3801a506ff0bbd813630",
"size": 1501295,
"sha256": "8f0f6c89137204a0616984f4d083786e2f23a66b48cb3446a77712d92ebeba17",
"executable": false
},
{
@@ -166,8 +166,8 @@
{
"dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py",
"size": 1498299,
"sha256": "a65844ce190649e5c0666f3de835030f85b97d68dd7a3801a506ff0bbd813630",
"size": 1501295,
"sha256": "8f0f6c89137204a0616984f4d083786e2f23a66b48cb3446a77712d92ebeba17",
"executable": false
},
{
+5
View File
@@ -147,6 +147,11 @@ EVENT_KEYS: dict[str, tuple[str, ...]] = {
# per core), once that directory is known. Not written when it is not:
# the summary's skipped then counts them (no_save_directory).
"saves": ("platform", "files", "folder"),
# Where saves is written, once per root (save, roms, configs or emulators)
# whose folder the run cannot place: why its files are left out, in
# words. The summary's skipped counts them (no_<root>_directory). A
# kind of its own, since schema 1 never adds a key to summary.
"unplaced": ("platform", "root", "why"),
"download": ("platform", "files", "bytes"),
"progress": ("files_done", "files_total", "bytes_done", "bytes_total"),
# Right after each progress event, and once when the files of a
+69 -42
View File
@@ -5,6 +5,7 @@ import os
import re
import sys
from pathlib import Path, PurePosixPath
from typing import NamedTuple
from installer.config_values import (
_CONFIGS_READ,
@@ -90,9 +91,25 @@ def _retroarch_config_at(bios_path: Path) -> tuple[Path, Path] | None:
return None
# Why a save directory cannot be told, where nothing more is known.
SAVE_NOT_KNOWN = "its place is not known"
class SaveUnknown(NamedTuple):
"""Why this run cannot tell the save directory: the cause, and the
remedy line mode joins to it."""
cause: str
remedy: str = ""
@property
def words(self) -> str:
return f"{self.cause}{self.remedy}"
def save_directory_for(
bios_path: Path, manifest: dict, override: Path | None = None,
) -> SavePlace | str:
) -> SavePlace | SaveUnknown:
"""The save directory the platform's frontend hands its cores, or why
this run cannot tell.
@@ -112,7 +129,7 @@ def save_directory_for(
"""
layout = manifest.get("save_directory")
if not layout:
return "the file list names no save directory for this platform"
return SaveUnknown("the file list names no save directory for this platform")
folder = layout["folder"]
listed = bool(layout["by_core"])
by_core = listed
@@ -121,8 +138,8 @@ def save_directory_for(
cfg_path, app_dir = found
for key in ("savefiles_in_content_dir", "sort_savefiles_by_content_enable"):
if _cfg_true(_retroarch_cfg_value(cfg_path, key)):
return (f"RetroArch keeps saves beside each game ({key} in {cfg_path}): "
"name the folder with --save-dir")
return SaveUnknown(f"RetroArch keeps saves beside each game ({key} in "
f"{cfg_path})", ": name the folder with --save-dir")
sort = _retroarch_cfg_value(cfg_path, "sort_savefiles_enable")
if sort is not None:
by_core = _cfg_true(sort)
@@ -143,7 +160,7 @@ def save_directory_for(
return SavePlace(bios_path / folder, by_core, listed)
# The wording of the run's end, said before the menu too: two wordings
# of one fact in one run, the first printing /mnt/e under WSL.
return "its place is not known. Name it with --save-dir"
return SaveUnknown(SAVE_NOT_KNOWN, ". Name it with --save-dir")
def place_save_entries(
@@ -153,9 +170,9 @@ def place_save_entries(
"""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. 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, each with why (the cause) and the
remedy line mode joins to it. 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:
@@ -172,13 +189,13 @@ def place_save_entries(
where += f"{os.sep}<core>"
_SAVE_WHERE[bios_path] = where
return files, []
_SAVE_WHY[bios_path] = place
kept = [entry for entry in files if entry.get("root") != "save"]
unplaced = [
{"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": "no_save_directory", "frontend": display,
"cores": entry.get("cores"), "root": "save",
"cores": entry.get("cores"), "root": "save", "why": place.cause,
"remedy": place.remedy,
**({"core_folder": entry["core_folder"]} if entry.get("core_folder") else {})}
for entry in saved
]
@@ -194,8 +211,7 @@ 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, the reason kept for
say_unplaced.
to the root, and the entries are left out, each with why in words.
"""
unplaced: list[dict] = []
for root in RELATIVE_ROOTS:
@@ -210,13 +226,13 @@ def place_relative_entries(
if folder is not None:
_RELATIVE_DIRS[(bios_path, root)] = folder
continue
_UNPLACED_WHY[(bios_path, root)] = (
f"{bios_path} is not its {layout.get('bios_folder') or 'BIOS'} folder")
why = 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,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": f"no_{root}_directory", "cores": entry.get("cores"), "root": root}
"reason": f"no_{root}_directory", "cores": entry.get("cores"), "root": root,
"why": why}
for entry in below
]
return files, unplaced
@@ -231,7 +247,7 @@ 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, the reason kept for say_unplaced.
follow, so its files are left out, each with why in words.
Otherwise the folder is the first of the searched places that exists,
the default one when none does, as the launcher searches them.
"""
@@ -250,6 +266,9 @@ def place_emulator_entries(
matches = True
else:
moved, matches = set(), False
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'}")
kept: list[dict] = []
unplaced: list[dict] = []
for entry in files:
@@ -276,38 +295,46 @@ def place_emulator_entries(
"dest": entry["dest"], "name": PurePosixPath(entry["dest"]).name,
"system": "", "systems": list(entry.get("systems") or []), "required": False,
"reason": "no_emulators_directory", "cores": entry.get("cores"),
"root": "emulators",
"root": "emulators", "why": 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"}
UNPLACED_FOLDERS = {"roms": "roms folder", "configs": "configs folder",
"emulators": "emulator folders"}
def say_unplaced(omitted: list[dict], bios_path: Path, display: str) -> None:
def unplaced_whys(omitted: list[dict]) -> dict[str, str]:
"""Per root (save, roms, configs, emulators), why the files read below
its folder are left out, as the entries carry it."""
whys: dict[str, str] = {}
for entry in omitted:
reason = str(entry.get("reason") or "")
if entry.get("why") and reason.startswith("no_") and reason.endswith("_directory"):
whys.setdefault(reason[3:-len("_directory")], str(entry["why"]))
return whys
def unplaced_line(display: str, root: str, count: int, why: str) -> str:
"""The files read from a roms, configs or emulator folder left out, and why."""
return (f"{_plural(count, 'file')} read from {display}'s {UNPLACED_FOLDERS[root]} "
f"left out: {why}.")
def say_unplaced(omitted: list[dict], 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():
whys = unplaced_whys(omitted)
for root in UNPLACED_FOLDERS:
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}.")
if left and root in whys:
print(f" {unplaced_line(display, root, left, whys[root])}")
# 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.
# Per BIOS folder, where its save files go in words: read by the lines that
# count them once a choice is made.
_SAVE_WHERE: dict[Path, str] = {}
_SAVE_WHY: dict[Path, str] = {}
def say_saves(plat: str, files: list[dict], omitted: list[dict], bios_path: Path,
@@ -356,10 +383,10 @@ def saves_line(display: str, count: int, where: str) -> str:
f"{shown_path(folder)}")
def unplaced_line(display: str, count: int, remedy: str) -> str:
def unplaced_save_line(display: str, count: int, remedy: str) -> str:
"""The files read from an unknown save directory, left out."""
return (f"{_plural(count, 'file')} read from {display}'s save directory left out: "
f"its place is not known. {remedy}")
f"{SAVE_NOT_KNOWN}. {remedy}")
def save_lines(files: list[dict], omitted: list[dict], bios_path: Path | None,
@@ -373,10 +400,10 @@ def save_lines(files: list[dict], omitted: list[dict], bios_path: Path | None,
where = _SAVE_WHERE.get(bios_path) if bios_path is not None else None
if count and where is not None:
lines.append(saves_line(display, count, where))
left = sum(1 for entry in omitted if entry.get("reason") == "no_save_directory")
left = [entry for entry in omitted if entry.get("reason") == "no_save_directory"]
if left:
why = _SAVE_WHY.get(bios_path) if bios_path is not None else None
lines.append(f"{_plural(left, 'file')} read from {display}'s save directory left "
f"out: {why}." if why else
unplaced_line(display, left, "Name it with --save-dir."))
why = next((entry for entry in left if entry.get("why")), None)
lines.append(f"{_plural(len(left), 'file')} read from {display}'s save directory "
f"left out: {why['why']}{why.get('remedy') or ''}." if why else
unplaced_save_line(display, len(left), "Name it with --save-dir."))
return lines
+15 -3
View File
@@ -40,12 +40,12 @@ from installer.filesystems import (
split_fat_refused,
)
from installer.frontend_folders import (
_SAVE_WHY,
place_emulator_entries,
place_relative_entries,
place_save_entries,
say_saves,
say_unplaced,
unplaced_whys,
)
from installer.games import fallback_lines, read_games
from installer.install_record import _RECORD_TAKEN, by_record, drop_recorded, record_menu_words
@@ -510,7 +510,17 @@ def _pass_version_and_saves(run: _InstallRun, p: _PlatformPass) -> None:
if not manifest.get("save_directory") and not run.packing:
# Its own list leaves these files out: naming the folder with
# --save-dir installs none of them, and was advised in a loop.
_SAVE_WHY[bios_path] = unlisted_saves_words(display)
why = unlisted_saves_words(display)
p.unplaced = [_unlisted_save(entry, why) for entry in p.unplaced]
p.omitted_files = [_unlisted_save(entry, why) for entry in p.omitted_files]
def _unlisted_save(entry: dict, why: str) -> dict:
"""entry, when read from a save directory the list names no place for,
with why in words and no remedy."""
if entry.get("reason") != "no_save_directory":
return entry
return {**entry, "why": why, "remedy": ""}
def _pass_games(run: _InstallRun, p: _PlatformPass) -> None:
@@ -736,7 +746,9 @@ def _pass_unplaced(run: _InstallRun, p: _PlatformPass) -> bool:
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)
say_unplaced(p.unplaced, p.display)
for root, why in unplaced_whys(p.omitted_files + p.unplaced).items():
EVENTS.emit("unplaced", platform=p.plat_name, root=root, why=why)
if args.list_systems or args.list_cores:
_print_choices(p.plat_name, p.files, p.omitted_files, args.list_systems, p.manifest)
+1
View File
@@ -217,6 +217,7 @@ def _start_run(state: TuiState, run: str) -> list[tuple]:
state.choices = state.set_aside = None
state.found, state.scanned, state.unreadable = [], [], []
state.check_summary = state.saves = None
state.unplaced_why = {}
state.version = state.version_short = state.board = ""
state.games = state.games_reading = state.games_unavailable = None
state.checked_flags = tui_flags(state)
+11 -6
View File
@@ -11,7 +11,7 @@ from installer.choices import available_choices, core_files, emulator_names
from installer.datadirs import select_data_directories
from installer.destination import dest_drive, shown_bios_folder
from installer.embedded import CARD_PLATFORMS
from installer.frontend_folders import save_directory_for, save_where_words
from installer.frontend_folders import SAVE_NOT_KNOWN, save_directory_for, save_where_words
from installer.games import GAMES_REASONS
from installer.manifest import OTHER_SYSTEMS, entry_copies
from installer.narrowing import narrow
@@ -367,11 +367,16 @@ def _save_folder_words(state: TuiState) -> str:
return _short_path(given, state.home)
if state.saves and state.saves.get("folder"):
return _short_path(Path(save_where_words(state.saves["folder"])[1]), state.home)
place = (save_directory_for(state.dest, state.manifest, None)
if state.dest is not None and state.manifest else None)
if isinstance(place, SavePlace):
return _short_path(spelled(place.directory), state.home)
return "not known"
# The cause the check gave, else the one the same rule gives here: a
# RetroArch keeping saves beside each game read as "not known".
why = state.unplaced_why.get("save")
if why is None:
place = (save_directory_for(state.dest, state.manifest, None)
if state.dest is not None and state.manifest else None)
if isinstance(place, SavePlace):
return _short_path(spelled(place.directory), state.home)
why = place.cause if place is not None else ""
return why if why and why != SAVE_NOT_KNOWN else "not known"
def _tui_card_bound(state: TuiState) -> tuple[str, str] | None:
+1 -1
View File
@@ -211,7 +211,7 @@ def _short_path(path: Path | None, home: Path) -> str:
# What a check run tells the screen, kept whole when Choose systems widens a
# --system plan: Back with the same ticks gives that plan back.
_CHECK_FIELDS = ("check", "files", "systems", "choices", "set_aside", "found", "scanned",
"unreadable", "saves", "check_summary", "checked_flags", "cli_systems",
"unreadable", "saves", "unplaced_why", "check_summary", "checked_flags", "cli_systems",
"facts", "ticked", "version", "board", "checked_dests", "games",
"games_unavailable")
+19 -7
View File
@@ -6,7 +6,7 @@ from typing import TYPE_CHECKING, NamedTuple
from installer.destination import _last_name
from installer.from_folders import MAX_SCANNED_FILES
from installer.frontend_folders import save_where_words
from installer.frontend_folders import SAVE_NOT_KNOWN, UNPLACED_FOLDERS, save_where_words, unplaced_line
from installer.install_record import record_changes, record_says
from installer.manifest import GAME_DATA, OTHER_SYSTEMS
from installer.offline import LOCAL, offline_named, offline_undo
@@ -400,17 +400,29 @@ def _saves_lines(state: TuiState, saves: dict | None, whole: bool = False) -> li
def _unplaced_lines(summary: dict | None, state: TuiState,
remedy: str = "") -> list[str]:
"""The files read from the frontend's save directory that the run left
out, that directory being unknown: said, never silent."""
count = sum(group.get("files", 0) for group in (summary or {}).get("skipped") or []
if group.get("reason") == "no_save_directory")
"""The files the run left out, their folder (save, roms, configs,
emulators) being unknown, with the reason line mode gives: said, never
silent."""
counts = {group.get("reason"): group.get("files", 0)
for group in (summary or {}).get("skipped") or []}
name = display_name(state.platform) if state.platform else "the frontend"
lines = _unplaced_save_lines(counts.get("no_save_directory", 0), name, state, remedy)
for root in UNPLACED_FOLDERS:
count, why = counts.get(f"no_{root}_directory", 0), state.unplaced_why.get(root)
if count and why:
lines.append(unplaced_line(name, root, count, why))
return lines
def _unplaced_save_lines(count: int, name: str, state: TuiState, remedy: str) -> list[str]:
"""The files read from the frontend's save directory left out, and why."""
if not count:
return []
name = display_name(state.platform) if state.platform else "the frontend"
left = f"{_plural(count, 'file')} read from {name}'s save directory left out"
if state.manifest and not state.manifest.get("save_directory"):
return [f"{left}.", _detail(f"{unlisted_saves_words(name)}.")]
return [f"{left}. {remedy or TUI_SAVE_REMEDY}", _detail("Its place is not known.")]
why = state.unplaced_why.get("save") or SAVE_NOT_KNOWN
return [f"{left}. {remedy or TUI_SAVE_REMEDY}", _detail(f"{why[:1].upper()}{why[1:]}.")]
# Said when ES-DE is found, and in fewer words where the long form would
+2
View File
@@ -117,6 +117,8 @@ def _take_check_event(state: TuiState, kind: str | None, event: dict) -> None:
f"{event['installed_version']}.")
elif kind == "saves":
state.saves = event
elif kind == "unplaced":
state.unplaced_why[str(event["root"])] = str(event["why"])
elif kind == "data" and state.check is not None:
state.check["data_bytes"] = event["bytes"]
elif kind == "space" and state.check is not None:
+3
View File
@@ -231,6 +231,9 @@ class TuiState:
self.check_summary: dict | None = None
# The saves event of the check: the files that go to the save folder.
self.saves: dict | None = None
# The unplaced events of the check: per root (save, roms, configs,
# emulators), why the files read below its folder are left out.
self.unplaced_why: dict[str, str] = {}
# The version event of the check: the list built for another
# release than the one this machine runs, said on the plan and the
# result as line mode says it.
+33
View File
@@ -35,6 +35,7 @@
"found",
"unreadable",
"saves",
"unplaced",
"download",
"progress",
"transfer",
@@ -129,6 +130,9 @@
{
"$ref": "#/$defs/saves"
},
{
"$ref": "#/$defs/unplaced"
},
{
"$ref": "#/$defs/download"
},
@@ -993,6 +997,35 @@
}
}
},
"unplaced": {
"type": "object",
"additionalProperties": false,
"required": [
"event",
"platform",
"root",
"why"
],
"properties": {
"event": {
"const": "unplaced"
},
"platform": {
"type": "string"
},
"root": {
"enum": [
"save",
"roms",
"configs",
"emulators"
]
},
"why": {
"type": "string"
}
}
},
"download": {
"type": "object",
"additionalProperties": false,
+2
View File
@@ -28,7 +28,9 @@ KEY_TYPES: dict[str, dict] = {
"installer", "os", "os_name", "stage", "reason", "platform", "message",
"folder", "dest", "system", "name", "bios_dir", "path", "member",
"list_version", "installed_version", "board", "core", "date", "moved_to", "problem",
"why",
), _TEXT),
"root": {"enum": ["save", "roms", "configs", "emulators"]},
"mode": {"enum": ["install", "check", "dry-run", "list", "remove", "restore", "pack"]},
"source": {"enum": ["remove", "install"]},
"state": {"enum": ["present", "wrong_hash", "missing"]},
+1 -1
View File
@@ -1376,7 +1376,7 @@ class OuterRootsAreUntrusted(unittest.TestCase):
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")
install.say_unplaced(chosen, "EmuDeck")
self.assertEqual(out.getvalue(), " 1 file read from EmuDeck's roms folder left out: "
f"{bios} is not its BIOS folder.\n")
+25
View File
@@ -4535,6 +4535,31 @@ class BackTicksAndSaveFolder(unittest.TestCase):
lines = install.tui_view(state, 40, 12)
self.assertIn(" Shared, counted once", lines)
def test_a_folder_left_out_gives_the_cause_line_mode_gives(self):
"""A RetroArch keeping saves beside each game read on the screen as
"Its place is not known", and the roms folder had no line at all."""
files = [{"dest": "keys.txt", "root": "save", "size": 1}]
why = install.SaveUnknown("RetroArch keeps saves beside each game "
"(savefiles_in_content_dir in /c/retroarch.cfg)",
": name the folder with --save-dir")
with mock.patch.object(install, "save_directory_for", return_value=why):
kept, left = install.place_save_entries(files, Path("/bios"), {}, None, "RetroArch")
roms = [{"dest": "pico-8/pico8_64", "root": "roms", "cores": ["x"]}]
_kept, beyond = install.place_relative_entries(roms, Path("/card/notbios"), {})
self.assertIn(f"left out: {why.words}.",
" ".join(install.save_lines(kept, left, Path("/bios"), "RetroArch")))
state = checked_state()
state.manifest = {**state.manifest, "save_directory": {"folder": "saves",
"by_core": True}}
state.unplaced_why = install.unplaced_whys(left + beyond)
summary = {"skipped": [{"reason": "no_save_directory", "files": 1},
{"reason": "no_roms_directory", "files": 1}]}
lines = install._unplaced_lines(summary, state)
self.assertIn(f"{why.cause}.", screen_text(lines))
self.assertIn("1 file read from RetroArch's roms folder left out: /card/notbios is "
"not its BIOS folder.", lines)
self.assertEqual(install._save_folder_words(state), why.cause)
def test_the_save_folder_remedy_is_the_same_on_both_screens(self):
summary = {"skipped": [{"reason": "no_save_directory", "files": 1}]}
state = checked_state()
+4 -4
View File
@@ -512,15 +512,15 @@ class TheInstallerFindsTheSaveDirectory(unittest.TestCase):
for key in ("savefiles_in_content_dir", "sort_savefiles_by_content_enable"):
with self.subTest(key=key):
found = self.place(f'{key} = "true"\n')
self.assertIsInstance(found, str)
self.assertIn(key, found)
self.assertIsInstance(found, install.SaveUnknown)
self.assertIn(key, found.cause)
def test_without_a_config(self):
self.assertEqual(self.place(None), install.SavePlace(self.app / "saves", True))
other = self.root / "BIOS"
found = install.save_directory_for(other, self.MANIFEST)
self.assertIsInstance(found, str)
self.assertIn("--save-dir", found)
self.assertIsInstance(found, install.SaveUnknown)
self.assertIn("--save-dir", found.words)
self.assertEqual(install.save_directory_for(other, self.MANIFEST, self.root / "s"),
install.SavePlace(self.root / "s", True))
+1
View File
@@ -2251,6 +2251,7 @@ other schemas under `api/v1/schemas/`.
| `found` | `platform`, `dest`, `folder`, `path`, `member`, `reason` | Each file to install that this machine already holds, after `check` and before anything is written, in `--check` and `--dry-run` too. `folder` is the `--from` folder as given, or the `bios_dir` of the check when the BIOS folder holds the file at another place, and then `reason` says where in words (`nested folder: ...` for a misplaced file, `the same file is at ...` for one the list installs there too). `path` is the file, and `member` the ZIP member holding the bytes when `path` is an archive, an empty string otherwise. Its copy is reported by a `downloaded` event |
| `unreadable` | `platform`, `folder`, `path`, `member`, `reason` | Each file in a `--from` folder that could not be read and may be one the run still needs, right after the `found` events: its size is that of a file no copy was found for, or unknown (a folder that could not be listed, a ZIP that would not open). `member` names the ZIP member, or is empty. `reason` says why in words (`Permission denied`, `it is encrypted, a password is needed`) |
| `saves` | `platform`, `files`, `folder` | After `choices` and before `checking`, when the files the run installs (once `--system` and the other choices narrowed the list) hold some read from the frontend's save directory and that directory is known: how many, and the `folder` they go to, where `<system>` and `<core>` stand for one folder per system or per core (the screen and `--plain` say it in words: "a folder per core under /sdcard/RetroArch/saves"). When it is not known, the files are counted in the summary's `skipped` instead (`no_save_directory`) |
| `unplaced` | `platform`, `root`, `why` | After `saves` when it is written, once per `root` (`save`, `roms`, `configs` or `emulators`) whose folder the run cannot place: `why` its files are left out, in words, as `--plain` says it ("RetroArch keeps saves beside each game"). The summary's `skipped` counts them (`no_<root>_directory`) |
| `download` | `platform`, `files`, `bytes` | Before the downloads start. Counts the files copied from this machine too |
| `progress` | `files_done`, `files_total`, `bytes_done`, `bytes_total` | At most every half second while bytes arrive |
| `transfer` | `bytes_local`, `bytes_network` | Right after each `progress` event, and once when the files of a `download` event are done. It splits `bytes_done`: `bytes_local` came from this machine (a copy found by `--from` or in the BIOS folder, the pack, a partial copy resumed), `bytes_network` from the network. A download speed is `bytes_network` over the time elapsed |