Filesystem¶
Bash¶
Tasks related to managing unix-level operations like file and directory management
-
tamr_toolbox.filesystem.bash.
create_directories
(directories, *, require_absolute_path=True, failure_if_exists=False)[source]¶ Creates directories recursively from a list of target directories if not already created
- Parameters
- Return type
- Returns
None
-
tamr_toolbox.filesystem.bash.
remove_directories
(directories, *, require_absolute_path=True, failure_if_not_exists=False, allow_recursive_deletes=False)[source]¶ Removes directories from a list of target directories if created. The directory must be empty
- Parameters
directories (
List
[Union
[Path
,str
]]) – List of directories to removerequire_absolute_path (
bool
) – Boolean flag indicating whether to require absolute paths.failure_if_not_exists (
bool
) – Boolean flag requiring failure if attempt to remove a directory that does not exist.allow_recursive_deletes (
bool
) – Boolean flag indicating whether to allow recursive deletion.
- Return type
- Returns
None
-
tamr_toolbox.filesystem.bash.
delete_old_files
(data_path, *, num_days_to_keep, exclude_paths=None)[source]¶ Find all files in the directory data_path and its subdirectory which have not been modified for a specified number of days and delete them except if their subdirectory is specified in the folders to exclude
- Parameters
- Return type
- Returns
A list of deleted files
- Raises
ValueError – if num_days_to_keep is less than 0
FileNotFoundError – if data_path doesn’t exist