code: def list_device_names(class_path, name_pattern, **kwargs):
      
  
      if not os.path.isdir(class_path):
          return
  
      def matches(attribute, pattern):
          try:
              with io.FileIO(attribute) as f:
                  value = f.read().strip().decode()
          except:
              return False
  
          if isinstance(pattern, list):
              return any([value.find(p) >= 0 for p in pattern])
          else:
              return value.find(pattern) >= 0
  
      for f in os.listdir(class_path):
          if fnmatch.fnmatch(f, name_pattern):
              path = class_path + '/' + f
              if all([matches(path + '/' + k, kwargs[k]) for k in kwargs]):
                  yield f
docs: This is a generator function that lists names of all devices matching the
      provided parameters.
  
      Parameters:
          class_path: class path of the device, a subdirectory of /sys/class.
              For example, '/sys/class/tacho-motor'.
          name_pattern: pattern that device name should match.
              For example, 'sensor*' or 'motor*'. Default value: '*'.
          keyword arguments: used for matching the corresponding device
              attributes. For example, address='outA', or
              driver_name=['lego-ev3-us', 'lego-nxt-us']. When argument value
              is a list, then a match against any entry of the list is
              enough.