geomancy.environment.sub_env#
- geomancy.environment.sub_env(string: str, missing_default: str = '', strip_values: bool = True, **kwargs) str#
Try to substitute environment variables in the string.
Parameters#
- string
The string to substituted
- missing_default
Missing environment variables will have this value placed instead
- strip_values
Remove whitespace at the start and end of non-quoted values
- kwargs
In addition to os.environ, search the given kwargs for matches.
Raises#
- EnvironmentError
Raised if an environment variable was not found and the
:?/?error directive was specified e.g.${MISSING?not found!}
Returns#
- substituted_str
The string with environment variables substituted
Notes#
This function follows the docker compose format.
Environment variable names are preceded with a
$character and may include braces. e.g.$VAR_NAMEor${VAR_NAME}Environment variables names may include directives for default values (
${MISSING-default}), errors for missing values (${missing?error) or replacement values (${MISSING+replace})