bobleesj.utils.io package
Submodules
bobleesj.utils.io.config module
bobleesj.utils.io.gh module
bobleesj.utils.io.folder module
- bobleesj.utils.io.folder.contains_file_type(dir_path: str, ext='.cif') bool [source]
Check if the specified directory contains at least one file with the given extension.
- Parameters:
dir_path (str) – The path to the directory to check.
ext (str, optional) – The file extension to look for (default is “.cif”).
- Returns:
True if at least one file with the given extension exists in the directory, False otherwise.
- Return type:
bool
Examples
>>> contains_file_type("/path/to/dir", ext=".cif") True
>>> contains_file_type("/empty/dir", ext=".txt") False
- bobleesj.utils.io.folder.get_file_paths(dir_path: str, ext='.cif') list[str] [source]
Return a list of file paths with a given extension in the specified directory.
- Parameters:
dir_path (str) – The path to the directory to search.
ext (str, optional) – The file extension to look for (default is “.cif”).
- Returns:
List of full file paths matching the given extension.
- Return type:
list of str
Examples
>>> get_file_paths("/path/to/dir", ext=".cif") ['/path/to/dir/sample1.cif', '/path/to/dir/sample2.cif']