refactor(io): Replace _get_io_path method with get_io_path utility

The `_get_io_path` method was removed from `InterfaceIoManager` and
replaced with the `get_io_path` utility function from `ios1_helper.py`
to reduce redundancy and improve code reusability.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2026-02-02 16:46:30 +01:00
parent afdae78336
commit 66c8c9851b
2 changed files with 8 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ from pydbus.generic import signal
from revpimodio2 import RevPiModIO, Cycletools
from revpimodio2.io import IntIO
from .ios1_helper import REVPI_DBUS_BASE_PATH, DbusInterfaceIo
from .ios1_helper import DbusInterfaceIo, get_io_object_path
class InterfaceIoManager:
@@ -46,11 +46,11 @@ class InterfaceIoManager:
self.lst_inp = []
for dev in self.modio.device:
for io in dev.get_inputs():
self.lst_inp.append(self._get_io_path(io.name))
self.lst_inp.append(get_io_object_path(io.name))
self.lst_out = []
for dev in self.modio.device:
for io in dev.get_outputs():
self.lst_out.append(self._get_io_path(io.name))
self.lst_out.append(get_io_object_path(io.name))
def _modio_cycle(self, ct: Cycletools) -> None:
for io_name in self._dc_io_interfaces:
@@ -60,9 +60,6 @@ class InterfaceIoManager:
self.IoChanged(interface.io.name,
Variant(interface.variant_type, interface.io.value))
def _get_io_path(self, io_name: str) -> str:
return f"{REVPI_DBUS_BASE_PATH}/io/{io_name}"
def GetAllInputs(self) -> list[str]:
return self.lst_inp
@@ -71,7 +68,7 @@ class InterfaceIoManager:
def Get(self, io_name) -> str:
if io_name in self.modio.io:
return self._get_io_path(io_name)
return get_io_object_path(io_name)
raise KeyError(f"No IO with name '{io_name}' found.")

View File

@@ -55,3 +55,7 @@ class DbusInterfaceIo:
@property
def name(self) -> str:
return self.io.name
def get_io_object_path(io_name: str) -> str:
return f"{REVPI_DBUS_BASE_PATH}/io/{io_name}"