def __getitem__(self, attribute): """ Get the given system ``attribute`` for the device. ``attribute`` is a unicode or byte string containing the name of the system attribute. Return the attribute value as byte string, or raise a :exc:`~exceptions.KeyError`, if the given attribute is not defined for this device. """ value = libudev.udev_device_get_sysattr_value( self.device, ensure_byte_string(attribute)) if value is None: raise KeyError(attribute) return value
def __contains__(self, attribute): value = libudev.udev_device_get_sysattr_value( self.device, ensure_byte_string(attribute)) return value is not None