- class wxflow.YAMLFile(path=None, data=None)[source]¶
Bases:
AttrDict
Reads a YAML file as an AttrDict and recursively converts nested dictionaries into AttrDict. This is the entry point for all YAML files.
- wxflow.parse_yaml(path=None, data=None, encoding='utf-8', loader=<class 'yaml.loader.SafeLoader'>)[source]¶
Load a yaml configuration file and resolve any environment variables The environment variables must have !ENV before them and be in this format to be parsed: ${VAR_NAME}. E.g.: database:
host: !ENV ${HOST} port: !ENV ${PORT}
- app:
log_path: !ENV ‘/var/${LOG_PATH}’ something_else: !ENV ‘${AWESOME_ENV_VAR}/var/${A_SECOND_AWESOME_VAR}’
- Parameters:
- Returns:
the dict configuration
- Return type:
Dict[str, Any]
Adopted from: https://dev.to/mkaranasou/python-yaml-configuration-with-environment-variables-parsing-2ha6
- wxflow.parse_j2yaml(path: str, data: Dict, searchpath: str | List = '/') Dict[str, Any] [source]¶
Description¶
Load a compound jinja2-templated yaml file and resolve any templated variables. The jinja2 templates are first resolved and then the rendered template is parsed as a yaml.
- Parameters:
path (str) – the path to the jinja2 templated yaml file
data (Dict[str, Any], optional) – the context for jinja2 templating
searchpath (str | List) – additional search paths for included jinja2 templates
- returns:
the dict configuration
- rtype:
Dict[str, Any]