lib/convert_inventory_to_machines: add classmethod for common conversion of Machine and InventoryMachine

This commit is contained in:
Johannes Kirschbauer
2025-07-04 10:18:14 +02:00
parent fcb38820ec
commit 91df5c258e
2 changed files with 19 additions and 7 deletions

View File

@@ -29,6 +29,15 @@ class Machine:
name: str
flake: Flake
@classmethod
def from_inventory(
cls,
name: str,
flake: Flake,
_inventory_machine: InventoryMachine,
) -> "Machine":
return cls(name=name, flake=flake)
def get_inv_machine(self) -> "InventoryMachine":
return get_machine(self.flake, self.name)