data0.paths

Functions

verify_path(path)

Verify that the filepath exists.

remove_non_empty_directory(base_dir)

Remove a non-empty directory and all its contents.

make_file_path(path)

Create a file path.

Module Contents

data0.paths.verify_path(path)

Verify that the filepath exists.

Check if the path to the data files exists and is valid. If not, raise an error.

Parameters:

path (str) – Relative path to the directory containing data files.

Raises:

FileNotFoundError – If the specified path does not exist.

Returns:

path – The verified path to the data files.

Return type:

str

Examples

>>> verify_path('datafiles/')
'datafiles/'
data0.paths.remove_non_empty_directory(base_dir)

Remove a non-empty directory and all its contents.

Recursively delete all files and directories in the given path.

Parameters:

base_dir (str) – Relative path to the directory to be removed.

data0.paths.make_file_path(path)

Create a file path.

Create the specified directory structure if the given path doesn’t exist.

Parameters:

path (str) – Relative path to make.

Returns:

path – The verified path to the data files.

Return type:

str

Examples

>>> make_file_path('datafiles/some/more/data/a_file.txt')
'datafiles/some/more/data/'