mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
refactor: name the new exceptions as errors
This commit is contained in:
1 parent
4de21e1157
commit
d2a61b4a89
6 files changed
+14
-14
No files matched your search
+1
-1
@@ -8,7 +8,7 @@ param(
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
|
||||
$defaultInstallSha256 = "edc57fe82a964b271bdae9d20985421f7a6ba88859f9c6926f323c909ec2d651"
|
||||
$defaultInstallSha256 = "0ed41bd31c30985281983309ec97162a7ae0176d737340bb728103efabae81f1"
|
||||
$maximumInstallerBytes = 2MB
|
||||
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
|
||||
$temporary = $null
|
||||
|
||||
+3
-3
@@ -1104,7 +1104,7 @@ def _region_rank(file_regions: set[str], requested: list[str]) -> int:
|
||||
|
||||
|
||||
def region_drops(
|
||||
entries: list[dict], requested: list[str], systems: "list[str] | None" = None
|
||||
entries: list[dict], requested: list[str], systems: list[str] | None = None
|
||||
) -> set[str]:
|
||||
"""Destinations a region priority list withdraws.
|
||||
|
||||
@@ -1807,7 +1807,7 @@ def _pick(title: str, rows: list[tuple[str, list[dict]]], ordered: bool = False)
|
||||
|
||||
def _prompt_custom_selection(
|
||||
plat: str, files: list[dict], omitted: list[dict]
|
||||
) -> "tuple[list[str], list[str], list[str]] | None":
|
||||
) -> tuple[list[str], list[str], list[str]] | None:
|
||||
"""Offer to narrow the install by system, core and region.
|
||||
|
||||
Enter installs everything, the default most runs want. Returns None
|
||||
@@ -1893,7 +1893,7 @@ def _print_choices(
|
||||
|
||||
def _requested_narrowing(
|
||||
args: argparse.Namespace, plat: str, files: list[dict], omitted: list[dict]
|
||||
) -> "tuple[list[str], list[str], list[str]] | None":
|
||||
) -> tuple[list[str], list[str], list[str]] | None:
|
||||
"""The systems, cores and regions named on the command line, checked."""
|
||||
if not (args.system or args.core or args.region):
|
||||
return None
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ esac
|
||||
TEMP_INSTALLER=""
|
||||
TEMP_DIRECTORY=""
|
||||
DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py"
|
||||
DEFAULT_INSTALL_SHA256="edc57fe82a964b271bdae9d20985421f7a6ba88859f9c6926f323c909ec2d651"
|
||||
DEFAULT_INSTALL_SHA256="0ed41bd31c30985281983309ec97162a7ae0176d737340bb728103efabae81f1"
|
||||
MAX_INSTALLER_BYTES=2097152
|
||||
|
||||
cleanup() {
|
||||
|
||||
@@ -189,7 +189,7 @@ def get_remote_sha(source_url: str, version: str) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
class NothingExtracted(Exception):
|
||||
class NothingExtractedError(Exception):
|
||||
"""An archive that yields no file for the cache.
|
||||
|
||||
Promoting it replaced the cache with an empty directory, recorded the new
|
||||
@@ -282,7 +282,7 @@ def _download_and_extract(
|
||||
file_count += 1
|
||||
|
||||
if not file_count:
|
||||
raise NothingExtracted(f"no file under {source_path} in the archive")
|
||||
raise NothingExtractedError(f"no file under {source_path} in the archive")
|
||||
_promote(extract_dir, cache_dir, Path(tmpdir))
|
||||
|
||||
return file_count
|
||||
@@ -345,7 +345,7 @@ def _download_and_extract_zip(
|
||||
file_count += 1
|
||||
|
||||
if not file_count:
|
||||
raise NothingExtracted("the archive holds no file to extract")
|
||||
raise NothingExtractedError("the archive holds no file to extract")
|
||||
# The old tree is stepped aside rather than deleted: removing it
|
||||
# first and then failing to move the new one in left the cache with
|
||||
# nothing at all, and the next run reads that as "never fetched".
|
||||
@@ -451,7 +451,7 @@ def _refresh_entry(
|
||||
OSError,
|
||||
tarfile.TarError,
|
||||
zipfile.BadZipFile,
|
||||
NothingExtracted,
|
||||
NothingExtractedError,
|
||||
) as exc:
|
||||
log.warning("[%s] download failed: %s", key, exc)
|
||||
return None
|
||||
|
||||
@@ -34,7 +34,7 @@ def _match_key(value: str) -> str:
|
||||
return re.sub(r"[^a-z0-9]", "", value.lower())
|
||||
|
||||
|
||||
class UnfinishedSplit(Exception):
|
||||
class UnfinishedSplitError(Exception):
|
||||
"""A pack lies beside its own parts: a split is running or was killed."""
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ def _read_record(dist: Path, tag: str) -> dict:
|
||||
assets: dict[str, list[Path]] = {}
|
||||
for path in sorted(dist.glob("*_BIOS_Pack*.zip")):
|
||||
assets.setdefault(split_pack.pack_of(path.name), []).append(path)
|
||||
for name, paths in sorted(assets.items()):
|
||||
for paths in assets.values():
|
||||
whole = [p for p in paths if not split_pack.is_part(p.name)]
|
||||
if whole and len(paths) > len(whole):
|
||||
raise UnfinishedSplit(
|
||||
raise UnfinishedSplitError(
|
||||
f"{whole[0].name} lies beside its parts: the split did not finish"
|
||||
)
|
||||
|
||||
@@ -133,7 +133,7 @@ def main() -> int:
|
||||
|
||||
try:
|
||||
record = build_record(args.dist, args.tag)
|
||||
except (UnfinishedSplit, ArtifactLockBusy) as exc:
|
||||
except (UnfinishedSplitError, ArtifactLockBusy) as exc:
|
||||
print(f"Error: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
if not record["packs"]:
|
||||
|
||||
@@ -359,7 +359,7 @@ class ReleaseRecord(unittest.TestCase):
|
||||
"Demo_2.0_BIOS_Pack.zip",
|
||||
{f"dir/file{n}.bin": bytes([n]) * 700 + bytes(range(256)) for n in range(6)},
|
||||
)
|
||||
with self.assertRaises(release_record.UnfinishedSplit):
|
||||
with self.assertRaises(release_record.UnfinishedSplitError):
|
||||
release_record.build_record(self.dist, "v1")
|
||||
|
||||
def test_a_directory_being_written_is_not_read(self):
|
||||
|
||||
Reference in new issue
Block a user