bridge.pipelines.utils.files module#

Utility functions for basic file handling.

bridge.pipelines.utils.files.check_file_with_extension_exists(in_folder_path, file_extension)[source]#

Check whether a folder contains at least one file with a given extension.

Parameters:
  • in_folder_path (str) – Path to the folder that should be searched.

  • file_extension (str) – File extension to look for, including the leading dot (e.g. ".md", ".json").

Returns:

True if at least one file with the specified extension is found anywhere under in_folder_path; False otherwise.

Return type:

bool

bridge.pipelines.utils.files.get_file_content(file_path)[source]#

Read the contents of a text file as UTF-8.

Parameters:

file_path (str | Path) – Path to the file whose contents should be read.

Returns:

The file contents as a string if the file exists, otherwise None.

Return type:

str | None

bridge.pipelines.utils.files.load_dict_from_yaml_file(file_path)[source]#

Load a YAML file and return its content as a dictionary.

Parameters:

file_path (str | Path) – Path to the YAML file to load.

Returns:

The parsed YAML content as a dictionary, or an empty dictionary if the file is missing, empty, invalid, or cannot be parsed.

Return type:

dict[str, Any]