Skip to main content

A simple library for adding include directives to a YAML file.

Project description

yaml-includes

A lightweight Python library for composing YAML files with #!include directives.

Installation

Install it using pip:

pip install yaml-includes

or poetry:

poetry add yaml-includes

Overview

yaml-includes lets you split large YAML configurations into smaller, reusable fragments. Any line matching #!include <path> is replaced with the contents of the referenced file before parsing.

Include syntax

[indent]#!include relative/path/to/fragment.yaml
  • Path is resolved relative to the file containing the directive.
  • Leading whitespace before #!include is prepended to every line of the included content, preserving YAML nesting.
  • Fragments can themselves contain #!include directives (recursive).

Example: indented include

# config.yaml
services:
  web:
    #!include web.yaml
# web.yaml
image: nginx
ports:
  - "80:80"

Result:

services:
  web:
    image: nginx
    ports:
      - "80:80"

Usage example

Loads a YAML file and resolves all #!include directives recursively.

import yaml
from yaml_includes import load_text

document = yaml.safe_load(load_text("config.yaml"))

Development

# Install project dependencies
make install

# Run linter
make lint

# Run tests
make test

# Run tests with coverage
make test-with-cov

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaml_includes-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaml_includes-0.1.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file yaml_includes-0.1.2.tar.gz.

File metadata

  • Download URL: yaml_includes-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for yaml_includes-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5fe231e0e9e0ec68e0e2a3b4f3a2c09a5a5924cb37260ccf6f4d7c4a1e04c1ec
MD5 ea81d3e5ee2175bdd5e2fa5172b6f642
BLAKE2b-256 4195c34c1e73779d63d292440d7a237f1ab65b3f33b021d5a8b77b6c3cf57925

See more details on using hashes here.

File details

Details for the file yaml_includes-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: yaml_includes-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for yaml_includes-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf3ee1990c1cccbdc1b5bcc56cebe33bea4b8ad0161fb641376e18a93aa69b85
MD5 2261ce91c127f23effe990b8b2a7dbeb
BLAKE2b-256 8bfb2a394dd8dd5d3420075ba2017ea3dcc33aa5c8972a15eda4b30b801262c5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page