def get_devices(self, hid_filter = None):
        """Filter a HID device list by current object parameters. Devices
        must match the all of the filtering parameters
        """
        if not hid_filter: #empty list or called without any parameters
            if type(hid_filter) == type(None):
                #request to query connected devices
                hid_filter = find_all_hid_devices()
            else:
                return hid_filter
        #initially all accepted
        results = {}.fromkeys(hid_filter)

        #the filter parameters
        validating_attributes = list(self.filter_params.keys())

        #first filter out restricted access devices
        if not len(results):
            return {}

        for device in list(results.keys()):
            if not device.is_active():
                del results[device]

        if not len(results):
            return {}

        #filter out
        for item in validating_attributes:
            if item.endswith("_includes"):
                item = item[:-len("_includes")]
            elif item.endswith("_mask"):
                item = item[:-len("_mask")]
            elif item +"_mask" in self.filter_params or item + "_includes" \
                    in self.filter_params:
                continue # value mask or string search is being queried
            elif item not in HidDevice.filter_attributes:
                continue # field does not exist sys.error.write(...)
            #start filtering out
            for device in list(results.keys()):
                if not hasattr(device, item):
                    del results[device]
                elif item + "_mask" in validating_attributes:
                    #masked value
                    if getattr(device, item) & self.filter_params[item + \
                            "_mask"] != self.filter_params[item] \
                            & self.filter_params[item + "_mask"]:
                        del results[device]
                elif item + "_includes" in validating_attributes:
                    #subset item
                    if self.filter_params[item + "_includes"] not in \
                            getattr(device, item):
                        del results[device]
                else:
                    #plain comparison
                    if getattr(device, item) != self.filter_params[item]:
                        del results[device]
            #
        return list(results.keys())
def get_devices ( self , hid_filter = None ) : if not hid_filter : if type ( hid_filter ) == type ( None ) : hid_filter = find_all_hid_devices ( ) else : return hid_filter results = { } . fromkeys ( hid_filter ) validating_attributes = list ( self . filter_params . keys ( ) ) if not len ( results ) : return { } for device in list ( results . keys ( ) ) : if not device . is_active ( ) : del results [ device ] if not len ( results ) : return { } for item in validating_attributes : if item . endswith ( "_includes" ) : item = item [ : - len ( "_includes" ) ] elif item . endswith ( "_mask" ) : item = item [ : - len ( "_mask" ) ] elif item + "_mask" in self . filter_params or item + "_includes" in self . filter_params : continue elif item not in HidDevice . filter_attributes : continue for device in list ( results . keys ( ) ) : if not hasattr ( device , item ) : del results [ device ] elif item + "_mask" in validating_attributes : if getattr ( device , item ) & self . filter_params [ item + "_mask" ] != self . filter_params [ item ] & self . filter_params [ item + "_mask" ] : del results [ device ] elif item + "_includes" in validating_attributes : if self . filter_params [ item + "_includes" ] not in getattr ( device , item ) : del results [ device ] else : if getattr ( device , item ) != self . filter_params [ item ] : del results [ device ] return list ( results . keys ( ) )
Filter a HID device list by current object parameters. Devices
        must match the all of the filtering parameters