nac-yaml
A Python library with common YAML utility functions supporting Network as Code.
Usage
Load and merge YAML files
from pathlib import Path
from nac_yaml.yaml import load_yaml_files
# Default is ruamel's round-trip loader (preserves formatting internally).
data = load_yaml_files([
Path("path/to/file1.yaml"),
Path("path/to/file2.yaml"),
])
# Use the safe loader to get native dict/list containers.
data_safe = load_yaml_files([
Path("path/to/file1.yaml"),
Path("path/to/file2.yaml"),
], typ="safe")
Note: when typ is not round-trip (e.g. "safe"), formatting features (quotes/comments/style) are not preserved.
Ansible Vault encrypted values
Values encrypted with Ansible Vault can be used with the !vault tag:
password: !vault |
$ANSIBLE_VAULT;1.2;AES256;dev
6535616566336139303566666336633163663431306337356461633439626638...
The vault password is read from the ANSIBLE_VAULT_PASSWORD environment variable, ANSIBLE_VAULT_ID is optional:
export ANSIBLE_VAULT_ID=dev
export ANSIBLE_VAULT_PASSWORD=Password123
Decryption requires ansible-core, either installed in the same Python environment (pip install nac-yaml[vault]) or available as ansible-vault command on PATH. All values are decrypted in a single batch after parsing. If a value cannot be decrypted, load_yaml_files() raises a VaultError for explicitly provided files, while files found in directories are skipped with a warning. Ansible Vault is not supported on Windows.
Installation
Using uv (recommended)
uv add nac-yaml
Using pip
pip install nac-yaml
Metadata
Release files for nac-yaml 2.1.0
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 |
|---|---|---|---|---|
| nac_yaml-2.1.0.tar.gz | 23.9 kB | Without provenance | Details for nac_yaml-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nac_yaml-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for nac_yaml-2.1.0-py3-none-any.whl |
Total release size: 42.0 kB
Release files / nac_yaml-2.1.0.tar.gz
| Download URL | nac_yaml-2.1.0.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8bbada6668d606a618da5659fdce784f616b62664ad4194499fd8b8cae6ddbf9
|
|
BLAKE2b-256 checksum How to use checksums |
9714b6526a33a3007470387c60841a2a527032e16024d5b951fe657ed769ef64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / nac_yaml-2.1.0-py3-none-any.whl
| Download URL | nac_yaml-2.1.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d517a1c100bd72a9c2069a6a5c4b40878606388c6ec26d01ad9f40bd67ab8f0
|
|
BLAKE2b-256 checksum How to use checksums |
40bedda69e71843d6d4be9f822cd96c9b69e234eac3fc49739e5a10891c18206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for nac-yaml 2.1.0
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.