autonomy_toolkit.utils.files
#
Provides helper methods for interacting with the filesystem.
Module Contents#
Functions#
|
Check if the passed filename is an actual file |
|
Search in the current directory and all directories above it |
|
Read in the passed file and return it as a string. |
- file_exists(filename: str, throw_error: bool = False, can_be_directory: bool = False) bool [source]#
Check if the passed filename is an actual file
- Parameters:
filename (str) – The filename to check
throw_error (bool) – If True, will throw an error if the file doesn’t exist. Defaults to False.
can_be_directory (bool) – If True, will check if it is a directory, in addition to a file
- Returns:
bool – True if the file exists, false otherwise
- Throws:
FileNotFoundError: If filename is not a file and throw_error is set to true