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:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user