Skip to main content

Yamlenv

Build Status PyPi package

Interpolate YaML files with environmental variables and other YaML files.

Given a YaML string like:

a: ${A}
b: 2

and an environmental variable $A with value hello, yamlenv.load would return:

{
    a: 'hello',
    b: 2
}

Including YAML literals as environment variables is also supported - so if the environment variable $A was set to false, yamlenv.load would return:

{
    a: False,
    b: 2
}

Default values are supported:

yamlenv.load('''
    a: ${A:-hello}
    b: 2
''') == {
    'a': 'hello',
    'b': 2
}

As in Bash, defaulting can be done with either :- (to not allow empty defaults) or with - to allow empty values.

The environmental variable can be embedded in a larger string, too:

yamlenv.load('''
    a: foo ${A:-bar} baz
    b: 2
''') == {
    'a': 'foo bar baz',
    'b': 2
}

More than one environmental variable can appear in a string:

yamlenv.load('''
    a: foo ${A:-bar} ${B:-baz}
    b: 2
''') == {
    'a': 'foo bar baz',
    'b': 2
}

YaML files can include other YaML files, too. E.g. if b.yaml contains “2”, then:

yamlenv.load('''
    a: 1
    b: !include b.yaml
''') == {
    'a': 1
    'b': 2
}

The included YaML file can be as complex as necessary.

More examples are available in the tests.

Metadata

Release files for yamlenv 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yamlenv 0.7.1
File Size Uploaded Provenance Actions
yamlenv-0.7.1.tar.gz 4.9 kB Without provenance Details for yamlenv-0.7.1.tar.gz

Release files / yamlenv-0.7.1.tar.gz

Download URL yamlenv-0.7.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1dd1e73826676686f153411c2fa06fd81524ab3ef7e71f8271828fb40e3d5b3f
BLAKE2b-256 checksum
How to use checksums
e671f07b6c05aeb376f23b10db873d2a0fba00891e8d37234925c8c486c11761
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.3

Security for yamlenv 0.7.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page