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.3.tar.gz (3.6 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.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yaml_includes-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 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.3.tar.gz
Algorithm Hash digest
SHA256 2f377ab985e9e85945539932b9665af111f8eb55d3c717ee3b5312ad6ff9ce01
MD5 d7971335456ab77a6414d9b13135971c
BLAKE2b-256 9ebc77fd0db607a7d57907b4c5d5ebe24ab1c7fc0a80223e36968f2b14813009

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yaml_includes-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5d793a0aa679e0bdc26ae3bd76da872bdb96a4866196128db6ced1a534e63a4b
MD5 018700553b979c2d1950e2ecaea571aa
BLAKE2b-256 a92f7463f14646722c11a0e575c0f30cdfe6dafab1cf4b909ca2b086b64f8698

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