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.1.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.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yaml_includes-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a43d56baec107d659d2fcf9a4ad30c4d410eea0b57158a29a0bed9bbfe699bf4
MD5 77a81fd30abd0ded92b61839bd4bae97
BLAKE2b-256 341c3aa219dc45fd596fd16b84161d1fd029c715b9fcdd998dd21d73c58543a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yaml_includes-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c92e19e348d8772e3f87b2cd0bcdbebd34cb5330cbadaecdefad014682661aa
MD5 43e6b9cbaa540b73b86b3f6cd034315a
BLAKE2b-256 b9a16deff8249b2f75cfe10c1261d6255c779fe1c8dd088f9e424777a4e4bc7b

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