config2py.errors#
Error classes for config2py.
Functions
|
Act on a config source |
Why |
|
|
Check that |
Exceptions
Base class for config2py errors. |
|
Warnings issued by config2py (e.g. permissions it could not tighten). |
|
Raised when a config file is not found. |
|
A folder used to store config values (which may be secrets) is owned by another user or writable by others, who could plant a symlink or file there to redirect or read those values (see i2mint/config2py#45). |
|
A path given as a config source is not an existing, readable file (it is missing, a folder, or unreadable), so it was read as empty (see i2mint/config2py#27 and /43). |
|
Raised when a value would be asked of the user but nobody can answer: stdin is closed, at end of file, or unreadable (cron, CI, a subprocess, pytest's output capture). |
- exception config2py.errors.Config2PyError[source]#
Bases:
ExceptionBase class for config2py errors.
- exception config2py.errors.Config2PyWarning[source]#
Bases:
UserWarningWarnings issued by config2py (e.g. permissions it could not tighten).
- exception config2py.errors.ConfigNotFound[source]#
Bases:
Config2PyErrorRaised when a config file is not found.
- exception config2py.errors.InsecureConfigFolderWarning[source]#
Bases:
Config2PyWarningA folder used to store config values (which may be secrets) is owned by another user or writable by others, who could plant a symlink or file there to redirect or read those values (see i2mint/config2py#45).
- exception config2py.errors.MissingConfigFileWarning[source]#
Bases:
Config2PyWarningA path given as a config source is not an existing, readable file (it is missing, a folder, or unreadable), so it was read as empty (see i2mint/config2py#27 and /43).
Bases:
ConfigNotFoundRaised when a value would be asked of the user but nobody can answer: stdin is closed, at end of file, or unreadable (cron, CI, a subprocess, pytest’s output capture). A
ConfigNotFound, soget_configmoves on to its next source or returns itsdefault(see i2mint/config2py#83).
- config2py.errors.report_missing_config_file(path, *, on_missing='warn', stacklevel=2, resolved_path=None)[source]#
Act on a config source
paththat is not an existing, readable file.The problem is told apart: missing, a directory, or unreadable (permission denied). A path that exists, is readable and isn’t a folder (a device or a pipe) is reported as not a regular file.
- Parameters:
on_missing (
str) –"warn"issues aMissingConfigFileWarning,"raise"raisesFileNotFoundError(IsADirectoryErrorfor a folder,PermissionErrorfor an unreadable file),"ignore"does nothing.stacklevel (
int) – Passed towarnings.warn, so the warning points at the caller’s code (2is the caller of this function).resolved_path (
str|PathLike|None) – Whatpathresolves to (~expanded, …), when that is what was actually looked at.pathis what the messages show.
- Return type: