def register(self, func: Callable, package: str = None) -> None: """Register skill package metadata Args: func (func): Function which will be called with a function to translate strings using the package translations at runtime package (str): Optional package name (usually __package__), if not given pytlas will try to determine it based on the call stack """ package = package or get_caller_package_name() self._data[package] = func self._logger.info('Registered "%s.%s" metadata', package, func.__name__)
def register(self, intent_name: str, func: Callable, package: str = None) -> None: """Register an intent handler. Args: intent_name (str): Name of the intent to handle func (callable): Handler to be called when the intent is triggered package (str): Optional package name (usually __package__), if not given pytlas will try to determine it based on the call stack """ package = package or get_caller_package_name() or func.__module__ self._data[intent_name] = func # Let's add the package to the func to tied together each registered resources func.__pytlas_package__ = package self._logger.info('Registered "%s.%s" which should handle "%s" intent', package, func.__name__, intent_name)
def register(self, name: str, func: Callable, package: str = None) -> None: """Register a new handler for the given hook. Args: name (str): Name of the hook to register to func (callable): Function to call upon hook trigger package (str): Optional package name (usually __package__), if not given pytlas will try to determine it based on the call stack """ pkg = package or get_caller_package_name() if name not in self._data: self._logger.warning( '"%s" doesn\'t look like a valid hook name, dismissing', name) else: self._data[name].append(func) self._logger.info('Registered "%s.%s" handler for hook "%s"', pkg, func.__name__, name)
def register(self, lang: str, func: Callable, package: str = None) -> None: """Register training data written using the chatl DSL language into the system. Args: lang (str): Language for which the training has been made for func (func): Function to call to return training data written using the chatl DSL package (str): Optional package name (usually __package__), if not given pytlas will try to determine it based on the call stack """ package = package or get_caller_package_name() if not should_load_resources(lang): # pragma: no cover self._logger.debug( 'Skipped "%s" training data for language "%s"', package, lang) else: self._set(func, package, lang) self._logger.info( 'Registered "%s.%s" training data for the lang "%s"', package, func.__name__, lang)
def new(func): s.register(ON_AGENT_DESTROYED, func, package or get_caller_package_name() or func.__module__) return func
def new(func): ts.register(lang, func, package or get_caller_package_name() or func.__module__) return func
def new(func): hs.register(intent_name, func, package or get_caller_package_name() or func.__module__) return func