Coverage for src/romfarmer/engine/transforms/wux.py: 41%

22 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-09-05 02:19 -0700

1"""WUX extract transform — extract .wux from a ZIP archive. 

2 

3Extracted from ``romfarmer.stages.unzip_wux.UnzipWUXStage``. 

4WUX is a compressed Wii U disc image used directly by Cemu. 

5""" 

6 

7from __future__ import annotations 

8 

9import zipfile 

10from collections.abc import Mapping 

11from pathlib import Path 

12 

13from .base import Transform, TransformError 

14 

15 

16class WUXExtractTransform: 

17 """Extract ``.wux`` files from a ZIP archive. 

18 

19 Recognised params: 

20 (none currently; all .wux members extracted) 

21 """ 

22 

23 name = "unzip-wux" 

24 

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("WUXExtractTransform: no input files provided") 

33 

34 zip_path = inputs[0] 

35 extracted: list[Path] = [] 

36 

37 with zipfile.ZipFile(zip_path, "r") as zf: 

38 members = [m for m in zf.namelist() if m.lower().endswith(".wux")] 

39 if not members: 

40 raise TransformError(f"No .wux 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) 

45 

46 return extracted 

47 

48 

49_: Transform = WUXExtractTransform()