# Path: uchroma/dbus_utils.py
# def _check_variance(items: list):
# def dbus_prepare(obj, variant: bool=False, camel_keys: bool=False) -> tuple:
#     def __init__(self, obj, interface_name, exclude=None):
#     def add_property(self, name: str, signature: str, writable: bool=False):
#     def add_method(self, method, *argspecs):
#     def add_signal(self, signal, *argspecs):
#     def _parse_traits(self):
#     def build(self) -> str:
#     def __init__(self, *args, **kwargs):
#     def __getattribute__(self, name):
#     def __setattr__(self, name, value):
# class DescriptorBuilder(object):
# class TraitsPropertiesMixin(object):
# 
# Path: uchroma/version.py

# 
# Path: uchroma/client/dbus_client.py
# class UChromaClient(object):
# 
#     def __init__(self):
#         self._bus = pydbus.SessionBus()
# 
# 
#     def get_device_paths(self) -> list:
#         dm = self._bus.get(SERVICE)
#         return dm.GetDevices()
# 
# 
#     def get_device(self, identifier):
#         if identifier is None:
#             return None
# 
#         use_key = False
#         if isinstance(identifier, str):
#             if identifier.startswith(BASE_PATH):
#                 return self._bus.get(SERVICE, identifier)
# 
#             if re.match(r'\w{4}:\w{4}.\d{2}', identifier):
#                 use_key = True
#             elif re.match(r'\d+', identifier):
#                 identifier = int(identifier)
#             else:
#                 return None
# 
#         for dev_path in self.get_device_paths():
#             dev = self.get_device(dev_path)
#             if use_key and identifier == dev.Key:
#                 return dev
#             elif identifier == dev.DeviceIndex:
#                 return dev
# 
#         return None
# 
# 
#     def get_layer(self, device, layer_idx):
#         layers = device.CurrentRenderers
#         if layer_idx >= len(layers):
#             raise ValueError("Layer index out of range")
# 
#         return self._bus.get(SERVICE, layers[layer_idx][1])


import logging
from argparse import ArgumentParser
from argcomplete import autocomplete
from uchroma.dbus_utils import dbus_prepare, snake_to_camel
from uchroma.version import __version__
from .dbus_client import UChromaClient
            if driver is None:
                self._parser.error("Invalid device: %s" % self._args.device)

        else:
            dev_paths = self._client.get_device_paths()
            if len(dev_paths) == 1:
                driver = self._client.get_device(dev_paths[0])
            else:
                self._list_devices(self._args)
                self._parser.error("Multiple devices found, select one with --device")

        return driver


    def set_property(self, target, name, value):
        name = snake_to_camel(name)
        if not hasattr(target, name):
            raise ValueError("Invalid property: %s" % name)
        cls_obj = getattr(target.__class__, name)
        if hasattr(cls_obj, '_type'):
            typespec = cls_obj._type
            if typespec == 's':
                value = str(value)
            elif typespec == 'd':
                value = float(value)
            elif typespec == 'u' or typespec == 'i':
                value = int(value)
            elif typespec == 'b':
                value = bool(value)
            else:

# Path: uchroma/dbus_utils.py
# def _check_variance(items: list):
# def dbus_prepare(obj, variant: bool=False, camel_keys: bool=False) -> tuple:
#     def __init__(self, obj, interface_name, exclude=None):
#     def add_property(self, name: str, signature: str, writable: bool=False):
#     def add_method(self, method, *argspecs):
#     def add_signal(self, signal, *argspecs):
#     def _parse_traits(self):
#     def build(self) -> str:
#     def __init__(self, *args, **kwargs):
#     def __getattribute__(self, name):
#     def __setattr__(self, name, value):
# class DescriptorBuilder(object):
# class TraitsPropertiesMixin(object):
# 
# Path: uchroma/version.py

# 
# Path: uchroma/client/dbus_client.py
# class UChromaClient(object):
# 
#     def __init__(self):
#         self._bus = pydbus.SessionBus()
# 
# 
#     def get_device_paths(self) -> list:
#         dm = self._bus.get(SERVICE)
#         return dm.GetDevices()
# 
# 
#     def get_device(self, identifier):
#         if identifier is None:
#             return None
# 
#         use_key = False
#         if isinstance(identifier, str):
#             if identifier.startswith(BASE_PATH):
#                 return self._bus.get(SERVICE, identifier)
# 
#             if re.match(r'\w{4}:\w{4}.\d{2}', identifier):
#                 use_key = True
#             elif re.match(r'\d+', identifier):
#                 identifier = int(identifier)
#             else:
#                 return None
# 
#         for dev_path in self.get_device_paths():
#             dev = self.get_device(dev_path)
#             if use_key and identifier == dev.Key:
#                 return dev
#             elif identifier == dev.DeviceIndex:
#                 return dev
# 
#         return None
# 
# 
#     def get_layer(self, device, layer_idx):
#         layers = device.CurrentRenderers
#         if layer_idx >= len(layers):
#             raise ValueError("Layer index out of range")
# 
#         return self._bus.get(SERVICE, layers[layer_idx][1])


# Path: uchroma/client/cmd.py
import logging
from argparse import ArgumentParser
from argcomplete import autocomplete
from uchroma.dbus_utils import dbus_prepare, snake_to_camel
from uchroma.version import __version__
from .dbus_client import UChromaClient

            if driver is None:
                self._parser.error("Invalid device: %s" % self._args.device)

        else:
            dev_paths = self._client.get_device_paths()
            if len(dev_paths) == 1:
                driver = self._client.get_device(dev_paths[0])
            else:
                self._list_devices(self._args)
                self._parser.error("Multiple devices found, select one with --device")

        return driver


    def set_property(self, target, name, value):
        name = snake_to_camel(name)
        if not hasattr(target, name):
            raise ValueError("Invalid property: %s" % name)
        cls_obj = getattr(target.__class__, name)
        if hasattr(cls_obj, '_type'):
            typespec = cls_obj._type
            if typespec == 's':
                value = str(value)
            elif typespec == 'd':
                value = float(value)
            elif typespec == 'u' or typespec == 'i':
                value = int(value)
            elif typespec == 'b':
                value = bool(value)
            else:

                value = dbus_prepare(value)[0]