Yaml Tag Extensions
Quick Guide
pip install YamlTagExtensions
Tags supported
!VARIABLE
# variables.yaml
country: Atlantis
name: Jane Doe
# deployment.yaml
conn_string: my_amazing_conn_string_xxxxxxxxxxxxxx
Use the tag to initialize settings / variables that needs to be accessed in the yaml.
The !variable / !VARIABLE / !Variable can be invoked as follows.
This approach requires to end the document using ---
Use yaml.load_all feature if this approach is chosen.
!VARIABLES
- '../test/resources/variable_loader/deployment.yaml'
- '../test/resources/variable_loader/variables.yaml'
---
person:
name: Jane Doe
country: !$ '.variables.country'
Assign a key before defining the !Variables.
Ending the document is not necessary, and yaml.load can be used.
setup: !VARIABLES
- '../test/resources/variable_loader/deployment.yaml'
- '../test/resources/variable_loader/variables.yaml'
!$
Use this tag to access the !Variables set into the loader context.
To access country value from variables.yaml
person:
name: Jane Doe
country: !$ '.variables.country' # .<file_name>.<attribute>
Also allows fetching of nested values / attributes.
Env variables can also be accessed using !$ detected by the presence of .env prefix in the fetch string.
database: !$ '.env.DATABASE_NAME' # .env.<attribute>
!FILE
Read a file and attach it as verbatim to a desired YAML location.
The read uses smart-open pkg for type resolution.
my_file_contents: !FILE
path: resources/file_loader/sample_file.txt
!TEMPLATE
Leverage the power of templating with Jinja2 + YAML.
Create a Jinja2 template / Yaml with Jinja2 syntax's, to create reusable configurations that render a YAML dynamically.
simple_job:
database_name: DB
table_name: person
sql:
- !TEMPLATE
path: "resources/j2_loader/insert_into_template.j2"
params:
name: John Doe
age: 30
country: Wakanda
- !Template
path: "resources/j2_loader/insert_into_template.j2"
params:
name: !$ '.variables.name'
age: 28
country: !$ '.variables.country'
# insert_into_template.j2
insert_into:
name: {{ name | upper }}
age: {{ age }}
country: {{ country }}
Rendered YAML
simple_job:
database_name: DB
table_name: person
sql:
- insert_into:
age: 30
country: Wakanda
name: JOHN DOE
- insert_into:
age: 28
country: Atlantis
name: JANE DOE
Initialize and load yaml using YTE
import yaml
from YamlTagExtensions.core import yte_loader
yaml.load_all(
open('<PATH TO THE YAML FILE>'),
Loader=yte_loader
)
import yaml
from YamlTagExtensions.core import yte_loader
yaml.load(
open('<PATH TO THE YAML FILE>'),
Loader=yte_loader
)
Metadata
Release files for yaml-tag-extension 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yaml-tag-extension-0.0.3.tar.gz | 6.1 kB | Without provenance | Details for yaml-tag-extension-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaml_tag_extension-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for yaml_tag_extension-0.0.3-py3-none-any.whl |
Total release size: 16.0 kB
Release files / yaml-tag-extension-0.0.3.tar.gz
| Download URL | yaml-tag-extension-0.0.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95dfc75e6bc7f2c314a2ad62ab9ec29be90c6213b8d7f0454b424520827f3a1c
|
|
BLAKE2b-256 checksum How to use checksums |
4dbcf2c5d62ce0fdcff941cabe870c5ac8eb1819bfadaba1f2cdc17245c35381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.13
|
Release files / yaml_tag_extension-0.0.3-py3-none-any.whl
| Download URL | yaml_tag_extension-0.0.3-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6e39ea514e6d465e9d6685924eb90e0165ab572e4ca155ef84978430f3f722e
|
|
BLAKE2b-256 checksum How to use checksums |
1c0fc3453b2bb56c4ef2ffe06bbc618b0c65af62424d9599e7e711aa76b80d1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.13
|
Security for yaml-tag-extension 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.