#NEWLINE# def _get_query_answer( self , port_list , filters ) : #NEWLINE# #INDENT# answers = [ ] #NEWLINE# for port in port_list : #NEWLINE# #INDENT# matched = True #NEWLINE# for ( key , search_values ) in filters . items ( ) : #NEWLINE# #INDENT# port_value = port . get ( key , None ) #NEWLINE# if ( not port_value ) : #NEWLINE# #INDENT# matched = False #NEWLINE# break #NEWLINE# #UNINDENT# if isinstance ( port_value , list ) : #NEWLINE# #INDENT# sub_answers = self . _get_query_answer ( port_value , search_values ) #NEWLINE# matched = ( len ( sub_answers ) > 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# matched = ( port_value in search_values ) #NEWLINE# #UNINDENT# if ( not matched ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if matched : #NEWLINE# #INDENT# answers . append ( port ) #NEWLINE# #UNINDENT# #UNINDENT# return answers