Coverage for src/romfarmer/engine/transforms/rvz.py: 41%
22 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-05 02:19 -0700
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-05 02:19 -0700
1"""RVZ extract transform — extract .rvz from a ZIP archive.
3Extracted from ``romfarmer.stages.unzip_rvz.UnzipRVZStage``.
4RVZ is Dolphin's native compressed format; no conversion is needed.
5"""
7from __future__ import annotations
9import zipfile
10from collections.abc import Mapping
11from pathlib import Path
13from .base import Transform, TransformError
16class RVZExtractTransform:
17 """Extract ``.rvz`` files from a ZIP archive.
19 Recognised params:
20 (none currently; all .rvz members extracted)
21 """
23 name = "unzip-rvz"
25 def run(
26 self,
27 inputs: list[Path],
28 params: Mapping[str, str],
29 scratch: Path,
30 ) -> list[Path]:
31 if not inputs:
32 raise TransformError("RVZExtractTransform: no input files provided")
34 zip_path = inputs[0]
35 extracted: list[Path] = []
37 with zipfile.ZipFile(zip_path, "r") as zf:
38 members = [m for m in zf.namelist() if m.lower().endswith(".rvz")]
39 if not members:
40 raise TransformError(f"No .rvz files found in {zip_path.name}")
41 for member in members:
42 zf.extract(member, scratch)
43 out = scratch / Path(member).name
44 extracted.append(out)
46 return extracted
49_: Transform = RVZExtractTransform()