def _has_attr(device, key, value):
    """
    Returns True if the udev Device has the attribute 'key' set to 'value'.
    """
    attrs = device.attributes
    return key in attrs.keys() and attrs[key] == value
