def from_directory(cls, path: Text) -> "Domain": """Loads and merges multiple domain files recursively from a directory tree.""" from rasa import data domain = Domain.empty() for root, _, files in os.walk(path, followlinks=True): for file in files: full_path = os.path.join(root, file) if data.is_domain_file(full_path): other = Domain.from_file(full_path) domain = other.merge(domain) return domain
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 from_directory( cls, path: Text, skill_imports: Optional[SkillSelector] = None ) -> "Domain": """Loads and merges multiple domain files recursively from a directory tree.""" domain = Domain.empty() skill_imports = skill_imports or SkillSelector.all_skills() for root, _, files in os.walk(path): if not skill_imports.is_imported(root): continue for file in files: full_path = os.path.join(root, file) if data.is_domain_file(full_path): other = Domain.from_file(full_path) domain = other.merge(domain) return domain