helper module
Define utility functions to test out the .toml config file.
- check_type(instance: type | tuple[type], name: str, *args: Any) None
Raise a warning if
argsare not all of typeinstance.Not matching the provided type does not stop the program from running.
- _find_according_to_nature(path: Path, nature: Literal['file', 'folder'] | None) bool
Helper function to check if the path matches the desired nature.
- find_path(toml_folder: Path | None, path: str | Path, nature: Literal['file', 'folder'] | None = None) Path
Look for the given path in all possible places, make it absolute.
We sequentially check and return the first valid path: 1. If
pathis aPathobject, resolve and check its existence. 2. Ifpathexists relative totoml_folder. 3. Ifpathis absolute.- Parameters:
toml_folder (pathlib.Path | None) – Folder where the
.tomlconfiguration file is.path (str | pathlib.Path) – Path to look for.
nature (Literal["file", "folder"] | None, optional) – The type of path to check: “file” or “folder”, or None to simply check existence.
- Returns:
path – Absolute path, whose existence has been checked.
- Return type:
- Raises:
FileNotFoundError – Raised if the required path does not exists.
- find_file(toml_folder: Path | None, path: str | Path, *, nature: Literal['file', 'folder'] | None = 'file') Path
Look for the given path in all possible places, make it absolute.
We sequentially check and return the first valid path: 1. If
pathis aPathobject, resolve and check its existence. 2. Ifpathexists relative totoml_folder. 3. Ifpathis absolute.- Parameters:
toml_folder (pathlib.Path | None) – Folder where the
.tomlconfiguration file is.path (str | pathlib.Path) – Path to look for.
nature (Literal["file", "folder"] | None, optional) – The type of path to check: “file” or “folder”, or None to simply check existence.
- Returns:
path – Absolute path, whose existence has been checked.
- Return type:
- Raises:
FileNotFoundError – Raised if the required path does not exists.
- find_folder(toml_folder: Path | None, path: str | Path, *, nature: Literal['file', 'folder'] | None = 'folder') Path
Look for the given path in all possible places, make it absolute.
We sequentially check and return the first valid path: 1. If
pathis aPathobject, resolve and check its existence. 2. Ifpathexists relative totoml_folder. 3. Ifpathis absolute.- Parameters:
toml_folder (pathlib.Path | None) – Folder where the
.tomlconfiguration file is.path (str | pathlib.Path) – Path to look for.
nature (Literal["file", "folder"] | None, optional) – The type of path to check: “file” or “folder”, or None to simply check existence.
- Returns:
path – Absolute path, whose existence has been checked.
- Return type:
- Raises:
FileNotFoundError – Raised if the required path does not exists.