File Utilities
File Utils
- class BBFileUtils
Bases:
objectUtilities for reading/writing files.
- classmethod delete_directory(directory_path, ignore_errors=False)
Delete a directory.
- classmethod delete_file(file_path, ignore_errors=False)
Delete a file.
- classmethod read_file(file_path, buffering=1, encoding='utf-8')
Read text from a file.
- Parameters:
- Returns:
The contents of the file as a string or None if an error occurred.
- Return type:
Union[str, None]
- classmethod write_file(file_path, text, buffering=1, encoding='utf-8', ignore_errors=False, remove_if_exists=False)
Write text to a file.
- Parameters:
file_path (str) – The file to write to.
text (str) – The text to write.
buffering (int, optional) – See the built-in python
open()function documentation for more details.encoding (str, optional) – See the built-in python
open()function documentation for more details.ignore_errors (bool, optional) – If True, any exceptions thrown will be ignored (Useful in preventing infinite loops)
remove_if_exists (bool, optional) – If True and the File exists already, it will be deleted before writing the data. If False and the File exists already, the data will be appended to the end of it. Default is False.
- Returns:
True if successful. False if not.
- Return type: