def _match_view_func(self): view_func = None intent_actions = self._intent_action_funcs.get(self.intent, []) if len(intent_actions) == 0: logger.critical("No action funcs defined for intent: {}".format( self.intent)) return view_func if self.has_live_context(): view_func = self._choose_context_view() if not view_func and self._missing_params: prompts = self._intent_prompts.get(self.intent) if prompts: param_choice = self._missing_params.pop() view_func = prompts.get(param_choice) logger.debug( "Matching prompt func {} for missing param {}".format( view_func.__name__, param_choice)) if not view_func and len(intent_actions) == 1: view_func = self._intent_action_funcs[self.intent][0] # TODO: Do not match func if context not satisfied if not view_func and len(intent_actions) > 1: view_func = intent_actions[0] msg = "Multiple actions defined but no context was applied, will use first action func" logger.warning(msg) return view_func
def _warndump(obj, indent=2, default=None, cls=None): msg = json.dumps(obj, indent=indent, default=default, cls=cls) logger.warning(msg)