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_include 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.0.tar.gz (3.1 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.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yaml_includes-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.10.18 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for yaml_includes-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f24142ffe4ff40ed6ca4aefbb7a712415808600125572be6a31dbb6ee3f8e22
MD5 891626fb4e74077c6b65f05eeb0eed95
BLAKE2b-256 5246bf82ea4197e6a19c24e553d32b8322ac099d79d292380f6e33571f4e2ed3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for yaml_includes-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90cc0ef51404d0e8ce62f32dba6a1238a70f205f41afcf24da205c549257c707
MD5 3b965591d6e8304fb59008fcaa423615
BLAKE2b-256 4d58534dc49b0824aa2a326a8af9b96e2fa1c546e4cc1f77dc5ae9a03e3c1e57

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