refactor: name the new exceptions as errors

This commit is contained in:
Abdessamad Derraz committed 2026-10-10 05:29:38 +02:00
1 parent 4de21e1157
commit d2a61b4a89
6 files changed
+14 -14

No files matched your search

+4 -4
View File
@@ -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
+4 -4
View File
@@ -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"]: