Coverage for src/romfarmer/planner/lowering/arcade.py: 45%

20 statements  

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

1"""Arcade lowering rule — copy arcade ZIP as-is. 

2 

3Arcade ROMs are already in the correct format (MAME/FBNeo expect raw ZIPs). 

4The action sequence just copies the source to the CAS. 

5 

6Stage sequence this replaces: 

7 CopyArcadeStage (and optionally RecompressArcadeStage) 

8""" 

9 

10from __future__ import annotations 

11 

12from romfarmer.ir.actions import ( 

13 Action, 

14 ArtifactDecl, 

15 InputRef, 

16 PendingRef, 

17 Retention, 

18 UnitPlan, 

19) 

20from romfarmer.ir.catalog import GameUnit 

21from romfarmer.ir.manifest import BuildManifest 

22from romfarmer.planner.lowering.base import ( 

23 FormatChain, 

24 make_action_id, 

25 source_action, 

26 static_tool_version, 

27 zero_prediction, 

28) 

29 

30 

31class ArcadeLoweringRule: 

32 """Lower an arcade ROM unit — passthrough (ZIP copy).""" 

33 

34 def __init__(self, action_cache: object | None = None) -> None: 

35 self._cache = action_cache 

36 

37 def lower( 

38 self, 

39 unit: GameUnit, 

40 chain: FormatChain, 

41 manifest: BuildManifest, 

42 ) -> UnitPlan: 

43 disc = unit.discs[0] 

44 src_path = disc.source.path 

45 step = 0 

46 actions: list[Action] = [] 

47 

48 src_act = source_action(unit, step, src_path, src_path.name, "zip") 

49 actions.append(src_act) 

50 step += 1 

51 src_ref: InputRef = PendingRef(src_act.action_id, 0) 

52 

53 pt_act = Action( 

54 action_id=make_action_id(str(unit.unit_id), step, "passthrough"), 

55 tool="passthrough", 

56 tool_version=static_tool_version("passthrough"), 

57 params={}, 

58 inputs=(src_ref,), 

59 outputs=( 

60 ArtifactDecl( 

61 logical_name=src_path.name, 

62 kind="zip", 

63 retention=Retention.TERMINAL, 

64 ), 

65 ), 

66 ) 

67 actions.append(pt_act) 

68 

69 return UnitPlan( 

70 unit=unit, 

71 actions=tuple(actions), 

72 predicted_output_bytes=unit.source_size, 

73 prediction=zero_prediction(), 

74 )