def _init_from_file(self, path: Text) -> None: path = os.path.abspath(path) if os.path.exists(path) and data.is_config_file(path): config = io_utils.read_config_file(path) parent_directory = os.path.dirname(path) self._init_from_dict(config, parent_directory) else: raise_warning(f"'{path}' does not exist or is not a valid config file.")
def _from_file(cls, path: Text, skill_selector: "SkillSelector") -> "SkillSelector": path = os.path.abspath(path) if os.path.exists(path) and data.is_config_file(path): config = io_utils.read_yaml_file(path) if isinstance(config, dict): parent_directory = os.path.dirname(path) return cls._from_dict(config, parent_directory, skill_selector) return cls.all_skills()
def _from_directory(cls, path: Text, skill_selector: "SkillSelector") -> "SkillSelector": for parent, _, files in os.walk(path): for file in files: full_path = os.path.join(parent, file) if data.is_config_file( full_path) and skill_selector.is_imported(full_path): skill_selector = cls._from_file(full_path, skill_selector) return skill_selector
def _from_file(cls, path: Text, skill_selector: "SkillSelector") -> "SkillSelector": from rasa import data # pytype: disable=pyi-error path = os.path.abspath(path) if os.path.exists(path) and data.is_config_file(path): config = io_utils.read_config_file(path) parent_directory = os.path.dirname(path) return cls._from_dict(config, parent_directory, skill_selector) return cls.all_skills()
def _init_from_directory(self, path: Text): for parent, _, files in os.walk(path): for file in files: full_path = os.path.join(parent, file) if not self.is_imported(full_path): # Check next file continue if data.is_domain_file(full_path): self._domain_paths.append(full_path) elif data.is_nlu_file(full_path): self._nlu_paths.append(full_path) elif data.is_story_file(full_path): self._story_paths.append(full_path) elif data.is_config_file(full_path): self._init_from_file(full_path)
def _init_from_directory(self, path: Text): for parent, _, files in os.walk(path, followlinks=True): for file in files: full_path = os.path.join(parent, file) if not self.is_imported(full_path): # Check next file continue if data.is_end_to_end_conversation_test_file(full_path): self._e2e_story_paths.append(full_path) elif Domain.is_domain_file(full_path): self._domain_paths.append(full_path) elif data.is_nlu_file(full_path): self._nlu_paths.append(full_path) elif data.is_story_file(full_path): self._story_paths.append(full_path) elif data.is_config_file(full_path): self._init_from_file(full_path)