refactor(io): Simplify generation of io object path

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2026-02-05 11:29:35 +01:00
parent 5528f6dff4
commit 3d64cd5837
2 changed files with 25 additions and 21 deletions

View File

@@ -36,8 +36,8 @@ class BusProviderIo(Thread):
super().__init__()
self._bus = SystemBus() if use_system_bus else SessionBus()
self._dc_io_interfaces = {}
self._loop = GLib.MainLoop()
self._lst_io_interfaces = []
self._modio = revpimodio2.RevPiModIO(
procimg=picontrol_device,
configrsc=config_rsc,
@@ -50,7 +50,7 @@ class BusProviderIo(Thread):
def run(self):
log.debug("enter BusProviderIo.run")
self._dc_io_interfaces.clear()
self._lst_io_interfaces.clear()
for io in self._modio.io:
interface = None
@@ -66,10 +66,10 @@ class BusProviderIo(Thread):
log.warning(f"can not create dbus interface for {io.name}: {e}")
if interface is not None:
self._dc_io_interfaces[io.name] = interface
self._lst_io_interfaces.append(interface)
lst_interfaces = [
(f"io/{io_name}", self._dc_io_interfaces[io_name]) for io_name in self._dc_io_interfaces
(interface.object_path, interface) for interface in self._lst_io_interfaces
]
lst_interfaces += [
(f"device/{device.position}", InterfaceDevice(self._bus, device))
@@ -79,7 +79,7 @@ class BusProviderIo(Thread):
self._bus.publish(
REVPI_DBUS_NAME,
InterfaceDeviceManager(self._modio),
InterfaceIoManager(self._modio, self._dc_io_interfaces),
InterfaceIoManager(self._modio, self._lst_io_interfaces),
*lst_interfaces,
)
except Exception as e: