def matchingDict(d, selection, require_existence=False):
 for (k, v) in list(selection.items()):
  if (k in d):
   if isinstance(v, list):
    if (d[k] not in v):
     return False
   elif (d[k] != v):
    return False
  elif require_existence:
   return False
 return True

def matchingDict ( d , selection , require_existence = False ) : for ( k , v ) in list ( selection . items ( ) ) : if ( k in d ) : if isinstance ( v , list ) : if ( d [ k ] not in v ) : return False elif ( d [ k ] != v ) : return False elif require_existence : return False return True
determines if the dictionary d conforms to the specified selection .