#NEWLINE# def query( self , texts ) : #NEWLINE# #INDENT# "\n        Passes user input to the appropriate module, testing it against\n        each candidate module's isValid function.\n\n        Arguments:\n        text -- user input, typically speech, to be parsed by a module\n        " #NEWLINE# for module in self . modules : #NEWLINE# #INDENT# for text in texts : #NEWLINE# #INDENT# if module . isValid ( text ) : #NEWLINE# #INDENT# self . _logger . debug ( ( "'%s' is a valid phrase for module " + "'%s'" ) , text , module . __name__ ) #NEWLINE# try : #NEWLINE# #INDENT# module . handle ( text , self . mic , self . profile ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . _logger . error ( 'Failed to execute module' , exc_info = True ) #NEWLINE# self . mic . say ( ( "I'm sorry. I had some trouble with " + 'that operation. Please try again later.' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _logger . debug ( ( "Handling of phrase '%s' by " + "module '%s' completed" ) , text , module . __name__ ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . _logger . debug ( ( 'No module was able to handle any of these ' + 'phrases: %r' ) , texts )