io
Input/Output operations.
Classes¶
Functions¶
make_sure_path_exists
¶
make_sure_path_exists(path: PathLike[str]) -> None
Ensure that a directory exists, creating it if it does not.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A directory tree path for creation.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ProjectForgeError
|
When there is an OSError |
parse_file
¶
parse_file(path: Union[str, Path]) -> Any
Read a file and parse its contents.
The file’s extension will be used to determine the file type, and the return type.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The path to the file to read
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
A data structure (from YAML, TOML, JSON) or a string. |
remove_paths
¶
remove_paths(
root: Path, paths_to_remove: Iterable[Path]
) -> None
Remove all paths in paths_to_remove from root.
Nabbed from Cruft: https://github.com/cruft/cruft/
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The absolute path of the directory requiring path removal
TYPE:
|
paths_to_remove
|
The set of relative paths to remove from
TYPE:
|
remove_readonly_bit
¶
remove_readonly_bit(
func: Callable[[str], None], path: str, _: Any
) -> None
Clear the readonly bit and reattempt the removal.
remove_single_path
¶
remove_single_path(path: Path) -> None
Remove a path with extra error handling for Windows.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The path to remove
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
IOError
|
If the file could not be removed |