refactor(io): Update get_*_object_path to accept objects instead

Modified `get_io_object_path` and `get_device_object_path` functions to
accept full `IOBase` and `Device` objects instead of string identifiers.
All properties are available in case of changing the object path format.

Signed-off-by: Sven Sager <s.sager@kunbus.com>
This commit is contained in:
Sven Sager
2026-02-06 08:41:29 +01:00
parent 0e69ef432b
commit 10ad65a62c
3 changed files with 7 additions and 6 deletions

View File

@@ -35,7 +35,7 @@ class InterfaceDevice:
def __init__(self, dbus: Union[SystemBus, SessionBus], device: Device):
self.dbus = dbus
self.device = device
self.object_path = get_device_object_path(device.position)
self.object_path = get_device_object_path(device)
@property
def bmk(self) -> str:

View File

@@ -62,7 +62,7 @@ class InterfaceInput:
self._raw = False
self.dbus = dbus
self.io = io
self.object_path = get_io_object_path(io.name)
self.object_path = get_io_object_path(io)
try:
self.variant_type = get_variant_type(self.io)
except ValueError:

View File

@@ -5,6 +5,7 @@
from logging import getLogger
from revpimodio2.device import Device
from revpimodio2.io import IOBase
log = getLogger(__name__)
@@ -13,12 +14,12 @@ REVPI_DBUS_NAME = "com.revolutionpi.ios1"
REVPI_DBUS_BASE_PATH = "/com/revolutionpi/ios1"
def get_io_object_path(io_name: str) -> str:
return f"{REVPI_DBUS_BASE_PATH}/io/{io_name}"
def get_io_object_path(io: IOBase) -> str:
return f"{REVPI_DBUS_BASE_PATH}/io/{io.name}"
def get_device_object_path(device_name: str) -> str:
return f"{REVPI_DBUS_BASE_PATH}/device/{device_name}"
def get_device_object_path(device: Device) -> str:
return f"{REVPI_DBUS_BASE_PATH}/device/{device.position}"
def get_variant_type(io: IOBase) -> str: