Skip to content

BluetoothServiceInfo

Base classes

Name Children Inherits
QBluetoothServiceInfo
PySide6.QtBluetooth
QBluetoothServiceInfo(self, /) -> None
MutableMapping
collections.abc
A MutableMapping is a generic container for associating

⋔ Inheritance diagram

graph TD
  4079714919["bluetooth.BluetoothServiceInfo"]
  2434744618["QtBluetooth.QBluetoothServiceInfo"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  1799060090["abc.MutableMapping"]
  4016029557["abc.Mapping"]
  2852422536["abc.Collection"]
  4051874921["abc.Sized"]
  2021119437["abc.Iterable"]
  1031828782["abc.Container"]
  2434744618 --> 4079714919
  37984305 --> 2434744618
  2751680898 --> 37984305
  1799060090 --> 4079714919
  4016029557 --> 1799060090
  2852422536 --> 4016029557
  4051874921 --> 2852422536
  2751680898 --> 4051874921
  2021119437 --> 2852422536
  2751680898 --> 2021119437
  1031828782 --> 2852422536
  2751680898 --> 1031828782

🛈 DocStrings

Bases: QBluetoothServiceInfo, MutableMapping

Enables access to the attributes of a Bluetooth service.

Also implements MutableMapping interface, can be used as a dicionary.

Source code in prettyqt/bluetooth/bluetoothserviceinfo.py
class BluetoothServiceInfo(
    QtBluetooth.QBluetoothServiceInfo, MutableMapping, metaclass=datatypes.QABCMeta
):
    """Enables access to the attributes of a Bluetooth service.

    Also implements MutableMapping interface, can be used as a dicionary.
    """

    def __getitem__(self, value: str | int | AttributeId):
        match value:
            case int():
                flag = value
            case str():
                if value not in ATTRIBUTE_IDS:
                    raise KeyError(value)
                flag = ATTRIBUTE_IDS[value].value
            case AttributeId():
                flag = value.value
            case _:
                raise KeyError(value)
        return self.attribute(flag)

    def __delitem__(self, value: str | int | AttributeId):
        match value:
            case int():
                flag = value
            case str():
                flag = ATTRIBUTE_IDS[value].value
            case AttributeId():
                flag = value.value
            case _:
                raise KeyError(value)
        return self.removeAttribute(flag)

    def __setitem__(self, index: str | int | AttributeId, value):
        """Set attribute."""
        match index:
            case int():
                flag = index
            case str():
                flag = ATTRIBUTE_IDS[index].value
            case AttributeId():
                flag = index.value
            case _:
                raise KeyError(index)
        return self.setAttribute(flag, value)

    def __contains__(self, value: object) -> bool:
        match value:
            case int():
                flag = value
            case str():
                if value not in ATTRIBUTE_IDS:
                    return False
                flag = ATTRIBUTE_IDS[value].value
            case AttributeId():
                flag = value.value
            case _:
                return False
        return self.contains(flag)

    def __iter__(self):
        """Iter the info attributes."""
        return iter(self.attributes())

    def __len__(self):
        return len(self.attributes())

__iter__()

Iter the info attributes.

Source code in prettyqt/bluetooth/bluetoothserviceinfo.py
def __iter__(self):
    """Iter the info attributes."""
    return iter(self.attributes())

__setitem__(index: str | int | AttributeId, value)

Set attribute.

Source code in prettyqt/bluetooth/bluetoothserviceinfo.py
def __setitem__(self, index: str | int | AttributeId, value):
    """Set attribute."""
    match index:
        case int():
            flag = index
        case str():
            flag = ATTRIBUTE_IDS[index].value
        case AttributeId():
            flag = index.value
        case _:
            raise KeyError(index)
    return self.setAttribute(flag, value)

:fa-brands-github: Show source on GitHub