# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-pyyaml-env-tag VERSION= 0.1 KEYWORDS= python VARIANTS= v11 v12 SDESC[v11]= YAML tag for environment variables (3.11) SDESC[v12]= YAML tag for environment variables (3.12) HOMEPAGE= https://github.com/waylan/pyyaml-env-tag CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/5a/66/bbb1dd374f5c870f59c5bb1db0e18cbe7fa739415a24cbd95b2d1f5ae0c4 DISTFILE[1]= pyyaml_env_tag-0.1-py3-none-any.whl:main DF_INDEX= 1 SPKGS[v11]= single SPKGS[v12]= single OPTIONS_AVAILABLE= PY311 PY312 OPTIONS_STANDARD= none VOPTS[v11]= PY311=ON PY312=OFF VOPTS[v12]= PY311=OFF PY312=ON DISTNAME= pyyaml_env_tag-0.1.dist-info GENERATED= yes [PY311].RUN_DEPENDS_ON= python-PyYAML:single:v11 [PY311].USES_ON= python:v11,wheel [PY312].RUN_DEPENDS_ON= python-PyYAML:single:v12 [PY312].USES_ON= python:v12,wheel [FILE:2233:descriptions/desc.single] # pyyaml_env_tag A custom YAML tag for referencing environment variables in YAML files. ## Installation Install `PyYAML` and the `pyyaml_env_tag` package with pip: `bash pip install pyyaml pyyaml_env_tag ` ### Enabling the tag To enable the tag, import and add the `construct_env_tag` constructor to your YAML loader of choice. ```python import yaml from yaml_env_tag import construct_env_tag yaml.Loader.add_constructor('!ENV', construct_env_tag) ``` Then you may use the loader as per usual. For example: ```python yaml.load(data, Loader=yaml.Loader) ``` ## Using the tag Include the tag `!ENV` followed by the name of an environment variable in a YAML file and the value of the environment variable will be used in its place. ```yaml key: !ENV SOME_VARIABLE ``` If `SOME_VARIABLE` is set to `A string!`, then the above YAML would result in the following Python object: ```python {'key': 'A string!'} ``` The content of the variable is parsed using YAML's implicit scalar types, such as string, bool, integer, float, datestamp and null. More complex types are not recognized and simply passed through as a string. For example, if `SOME_VARIABLE` was set to the string `true`, then the above YAML would result in the following: ```python {'key': True} ``` If the variable specified is not set, then a `null` value is assigned as a default. You may define your own default as the last item in a sequence. ```yaml key: !ENV [SOME_VARIABLE, default] ``` In the above example, if `SOME_VARIABLE` is not defined, the string `default` would be used instead, as follows: ```python {'key': 'default'} ``` You may list multiple variables as fallbacks. The first variable which is set is used. In any sequance with more than one item, the last item must always be a default value and will not be resolved as an environment variable. ```yaml key: !ENV [SOME_VARIABLE, FALLBACK, default] ``` As with variable contents, the default is resolved to a Python object of the implied type (string, bool, integer, float, datestamp and null). When `SOME_VARIABLE` is not set, all four of the following items will resolve to the same value (`None`): ```yaml - !ENV SOME_VARIABLE - !ENV [SOME_VARIABLE] - !ENV [SOME_VARIABLE, ~] [FILE:114:distinfo] af31106dec8a4d68c60207c1886031cbf839b68aa7abccdb19868200532c2069 3911 pyyaml_env_tag-0.1-py3-none-any.whl