Directory
provide.foundation.file.directory
¶
TODO: Add module docstring.
Functions¶
ensure_dir
¶
Ensure directory exists with proper permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Directory path |
required |
mode
|
int
|
Directory permissions |
493
|
parents
|
bool
|
Create parent directories if needed |
True
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object for the directory |
Source code in provide/foundation/file/directory.py
ensure_parent_dir
¶
Ensure parent directory of file exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path | str
|
File path whose parent to ensure |
required |
mode
|
int
|
Directory permissions |
493
|
Returns:
| Type | Description |
|---|---|
Path
|
Path object for the parent directory |
Source code in provide/foundation/file/directory.py
safe_rmtree
¶
Remove directory tree safely.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Directory to remove |
required |
missing_ok
|
bool
|
If True, don't raise error if doesn't exist |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if removed, False if didn't exist |
Raises:
| Type | Description |
|---|---|
OSError
|
If removal fails and directory exists |