def _collect_yaml_files_from_path(path: Union[Text, Path]) -> List[Text]: path = os.path.abspath(path) if os.path.isfile(path): yaml_files = [ yaml_file for yaml_file in [path] if is_likely_yaml_file(yaml_file) ] if not yaml_files: raise InvalidMarkerConfig( f"Could not find a yaml file at '{path}'.") elif os.path.isdir(path): yaml_files = [ os.path.join(root, file) for root, _, files in os.walk(path, followlinks=True) for file in files if is_likely_yaml_file(file) ] if not yaml_files: raise InvalidMarkerConfig( f"Could not find any yaml in the directory tree rooted at '{path}'." ) else: raise InvalidMarkerConfig( f"The given path ({path}) is neither pointing to a directory " f"nor a file. Please specify the location of a yaml file or a " f"root directory (all yaml configs found in the directories " f"under that root directory will be loaded). " f"Refer to the docs for more information: {DOCS_URL_MARKERS} ") return yaml_files
def is_domain_file(filename: Text) -> bool: """Checks whether the given file path is a Rasa domain file. Args: filename: Path of the file which should be checked. Returns: `True` if it's a domain file, otherwise `False`. Raises: YamlException: if the file seems to be a YAML file (extension) but can not be read / parsed. """ from rasa.shared.data import is_likely_yaml_file if not is_likely_yaml_file(filename): return False content = rasa.shared.utils.io.read_yaml_file(filename) return any(key in content for key in ALL_DOMAIN_KEYS)
def is_domain_file(filename: Text) -> bool: """Checks whether the given file path is a Rasa domain file. Args: filename: Path of the file which should be checked. Returns: `True` if it's a domain file, otherwise `False`. """ from rasa.shared.data import is_likely_yaml_file if not is_likely_yaml_file(filename): return False try: content = rasa.shared.utils.io.read_yaml_file(filename) if any(key in content for key in ALL_DOMAIN_KEYS): return True except YAMLError: pass return False