Skip to main content

Configuration parser based on YAML-Files with support for variables, overlaying and hierarchies

Project description

Build Status Documentation Status Version Downloads License (MIT) Supported Python versions

Configcrunch is a Python library written in Rust for reading YAML-based configuration files. It aims to be simple and fast while also providing some very powerful features.

Configcrunch is compatible with Python 3.11 and up.

Install it via pip: pip install configcrunch

Features:

  • Read configuration files from YAML files.

  • Define various types of configuration files, that can be validated via a schema.

  • Types of configuration files are defined as separate Python classes.

  • Documents can be configured to contain nested documents of any type.

  • Documents can contain Minijinja templates that can reference any other field inside the same or parent document.

  • The classes that represent your document types can contain methods that can be used inside the configuration files.

  • Documents can reference documents from other files. Configcrunch will merge them together. You decide where referenced documents are looked up.

  • Configuration objects can also be created without YAML files, by using ordinary Python dicts.

  • All features are optional.

Used by:

  • Riptide

  • (Your project here! Open an issue.)

By default Configcrunch uses schema to validate schemas. But you can also use your own validation logic!

Example

This is an example that uses most of the features described above, using two document types.

# doc1.yml - Type: one
one:
    name: Document
    number: 1
    sub:
        # Sub-document of type "two"
        $ref: /doc2
        two_field: "{{ parent().method() }}"
# <lookup path>/doc2.yml - Type: two
two:
    name: Doc 2
    number: 2
    two_field: This is overridden
# classes.py
from schema import Schema, Optional

from configcrunch import YamlConfigDocument, DocReference, variable_helper


class One(YamlConfigDocument):
    @classmethod
    def header(cls) -> str:
        return "one"

    @classmethod
    def schema(cls) -> Schema:
        return Schema(
            {
                Optional('$ref'): str,  # reference to other One documents
                'name': str,
                'number': int,
                Optional('sub'): DocReference(Two)
            }
        )

    @classmethod
    def subdocuments(cls):
        return [
            ("sub", Two)
        ]

    @variable_helper
    def method(self):
        return "I will return something"


class Two(YamlConfigDocument):
    @classmethod
    def header(cls) -> str:
        return "two"

    @classmethod
    def schema(cls) -> Schema:
        return Schema(
            {
                Optional('$ref'): str,  # reference to other Two documents
                'name': str,
                'number': int,
                'two_field': str
            }
        )

    @classmethod
    def subdocuments(cls):
        return []

The document “one.yml” can then be read via Python:

>>> import yaml
>>> from classes import One
>>> doc = One.from_yaml('./doc1.yml')
>>> doc.resolve_and_merge_references(['<lookup path>'])
>>> doc.process_vars()
>>> print(yaml.dump(doc.to_dict(), default_flow_style=False))
one:
  name: Document
  number: 1
  sub:
    name: Doc 2
    number: 2
    two_field: I will return something

Tests

Inside the configcrunch.tests package are tests.

To run the tests, see run_tests.sh.

Documentation

The complete documentation can be found at Read the Docs (or in the docs directory).

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

configcrunch-2.1.1.tar.gz (38.2 kB view details)

Uploaded Source

Built Distributions

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

configcrunch-2.1.1-cp314-cp314t-win_amd64.whl (918.2 kB view details)

Uploaded CPython 3.14tWindows x86-64

configcrunch-2.1.1-cp314-cp314t-win32.whl (858.6 kB view details)

Uploaded CPython 3.14tWindows x86

configcrunch-2.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.28+ x86-64

configcrunch-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

configcrunch-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14tmacOS 10.15+ x86-64

configcrunch-2.1.1-cp314-cp314-win_amd64.whl (922.1 kB view details)

Uploaded CPython 3.14Windows x86-64

configcrunch-2.1.1-cp314-cp314-win32.whl (862.3 kB view details)

Uploaded CPython 3.14Windows x86

configcrunch-2.1.1-cp314-cp314-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

configcrunch-2.1.1-cp314-cp314-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

configcrunch-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

configcrunch-2.1.1-cp313-cp313-win_amd64.whl (888.8 kB view details)

Uploaded CPython 3.13Windows x86-64

configcrunch-2.1.1-cp313-cp313-win32.whl (846.2 kB view details)

Uploaded CPython 3.13Windows x86

configcrunch-2.1.1-cp313-cp313-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

configcrunch-2.1.1-cp313-cp313-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

configcrunch-2.1.1-cp313-cp313-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

configcrunch-2.1.1-cp312-cp312-win_amd64.whl (889.0 kB view details)

Uploaded CPython 3.12Windows x86-64

configcrunch-2.1.1-cp312-cp312-win32.whl (846.3 kB view details)

Uploaded CPython 3.12Windows x86

configcrunch-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

configcrunch-2.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

configcrunch-2.1.1-cp312-cp312-macosx_10_13_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

configcrunch-2.1.1-cp311-cp311-win_amd64.whl (888.9 kB view details)

Uploaded CPython 3.11Windows x86-64

configcrunch-2.1.1-cp311-cp311-win32.whl (847.4 kB view details)

Uploaded CPython 3.11Windows x86

configcrunch-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

configcrunch-2.1.1-cp311-cp311-macosx_11_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

configcrunch-2.1.1-cp311-cp311-macosx_10_12_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

Details for the file configcrunch-2.1.1.tar.gz.

File metadata

  • Download URL: configcrunch-2.1.1.tar.gz
  • Upload date:
  • Size: 38.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1.tar.gz
Algorithm Hash digest
SHA256 b56162bdd0c5396eb267f03d1ab458cfbdafed8eb3c8b52dc4bd49c2e3bfb49c
MD5 4895419e5a1e43870333eec1457fbd22
BLAKE2b-256 dc65e0e607f056ba9b95e1b519765947fe954491b945b8b10f17ca26b5ac95fa

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 2a736e2df28b5cac821b76436ddc4f319002b177f1b863222a795bcdf1a66fd9
MD5 ab0a3efde942b81ca20f80e3eb6d6a51
BLAKE2b-256 ed5acab8fbc09af15b8dda55c39a739357ec55f4f4ae3c27c28161992f100b57

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314t-win32.whl.

File metadata

  • Download URL: configcrunch-2.1.1-cp314-cp314t-win32.whl
  • Upload date:
  • Size: 858.6 kB
  • Tags: CPython 3.14t, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 8d29bb8a90d53fe7d4c3d71a83e54ef0a5984069b12f7f385c8954e2159fbfdb
MD5 ff80cd9cf4688c61d44490b91a4f266a
BLAKE2b-256 4762ac923cf036f2b99edec423f12c260107dd6456d1e52fc11c69d8036de6af

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314t-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a29d5963cce5f5315188b854a8e920b4382947c82463785f326f04c14f538cc
MD5 15d2ecfe0b7c51bb39c5a6448d94b16e
BLAKE2b-256 fde7166ab3abee09ced7419f4399a1f970eede65794df00d6ff67e80f41d5235

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83e03e0b049f54bfa7d005a938e434614d16007194b0b0f5e2c0aa3ea0bac0a3
MD5 e19c70b4aa584ded0d4f1edbdc1c8c47
BLAKE2b-256 c63e182d5b9008383d8f9727dd7d88ea71651721c369cc5e6e90a43292374ff5

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e12731c32050cf5316c765a5893ac281c3b8f616c190451abcc88a12aeac459d
MD5 b82b7613db2ba8746870780a1ff2a965
BLAKE2b-256 0e7341576953e4d6dba609a40726ef75c39fddd4e226e8e42707c708326c1f53

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 7bd9153be76efb1bc2433ecf3fa8c4cbc88cca0d88360a00a6048906c1b709d5
MD5 4782b9422200d77aaa04e20f2ec0503f
BLAKE2b-256 beb2c6185482425800075765c8a942b16d488da88c3174b92a94876edde7da5e

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314-win32.whl.

File metadata

  • Download URL: configcrunch-2.1.1-cp314-cp314-win32.whl
  • Upload date:
  • Size: 862.3 kB
  • Tags: CPython 3.14, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 c3fa0b7239efe1d27b181c34e109263336d1169b0bf130422f20f60a2747d171
MD5 07265d337b0aa1be6e2bac1c4b4c4a88
BLAKE2b-256 21aaf974b8ad7859b9e72318fcae37f24136c3b9de412ea657bd7534c0e87141

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ce0aac37ac9a6d05e3de98d6beece49d6ccdb3c84c2fe52bb4c5d1e8bede97e6
MD5 2dd0b4ba53bda771854d6b831e6f298f
BLAKE2b-256 2079a06349a92e28b95c72aeaeea54e97976ce7a36d7b09a1a0f6a57e761aca8

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0ff68fcff568df8548164a6b3c9bf8ff2b791aea3f9ed299f1d96f1f6156cd9
MD5 3d06f84012c6783913cd7d7321dfd219
BLAKE2b-256 aa78c93ab135f5d92e1ce6546eb81713dc0ab1e47fe3a3d39d92a043579d658c

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 056fe7b06528b1bb3610e7e47bfaf4635d1e34ea8a6e8eb9a2122fa4da32e7fd
MD5 cc1c0c26bc5349e880b5d33d6af0d65a
BLAKE2b-256 46861f53f8c13e368d36c7d0d04001f354c9182a823b0e4f64659120586babce

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 60b8dc95636a14c426dd0d48a5123c4d3a04653cad161cc3e5fbf0728b5a405b
MD5 4fe7fd051b3cece98b4c4c481c2a92bc
BLAKE2b-256 8a7cbe5dd34c0cae5687fa348a26a00a01b362dbec881c0721f2804e51034f48

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp313-cp313-win32.whl.

File metadata

  • Download URL: configcrunch-2.1.1-cp313-cp313-win32.whl
  • Upload date:
  • Size: 846.2 kB
  • Tags: CPython 3.13, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 cf1a15f0cdc397cee6cd310c6e6e6b07285f48289f069c36dad53a3757b168a9
MD5 32be0a8bef87bba286566b2e7ec2907c
BLAKE2b-256 ffa5f62ab65ec0c15e1ca804377a4e14f803351c64e36d9ff48077c4c6becba6

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e204c61f05ba14819143a4f807edc1cedb2d5b4587a30e56ba1f4d8055986dd8
MD5 374946f3fd0a7ddf4c54c4331905c4fa
BLAKE2b-256 68ebf6b6ea2fec2d7f11fce1f064f83877b7bd17c9e30dd4c251abe356ce8a3f

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 648a8ba564aae60711368d05162dd67b404cfa63cf70c52422532eddb95d3bfa
MD5 9bb5655d3a86ac48a0e221c9b242c1c3
BLAKE2b-256 a74f55e49a3b9fba26195cd4ad1259a4b727198ba97e095d8c780f8752bb83a6

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 58dddb2de2fedfa5b9267e8d7c5f7d5558c3c25175eeb18d24e6f5ca90673210
MD5 fed69738e9cafe8fb44479035057023f
BLAKE2b-256 21dad3d804be5c3ce01f24ad5d2ead5fb72c70e2b2dfd6c6062b8a014dd62b8c

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 05a1c3a3e7513871efc3aff6b4bd13fb50fbebb1c757b833d90868de0d62d9dc
MD5 8722b46f907791f8731019bc76f394d7
BLAKE2b-256 3ec77fc533878e4b4fc7eda6d9bd943bd152caadb3690f9ffbd35e8c727e7072

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp312-cp312-win32.whl.

File metadata

  • Download URL: configcrunch-2.1.1-cp312-cp312-win32.whl
  • Upload date:
  • Size: 846.3 kB
  • Tags: CPython 3.12, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 2949d15ac1aa8c4d1d5f519a21453d335c5156122298a24251357a96cdcb44e8
MD5 ee7e0127faaa5b4bedd99668f623c29c
BLAKE2b-256 ebc16fc607422b243d4a13e22ae0ee88e647dd87525c75ebd2b6e959a12f3597

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 30107c6538a568cdf21e5951e42f67d4a0cda5d5e5525ed7f6aa0090e7e5888a
MD5 afc8a7ca32a7bc19a9869792bed3f8cf
BLAKE2b-256 d7b4c8f306f6818f68d8cbd1957f80aa305b459dd5c59c9894b10b668aee17ab

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1053b84c911b26618f267752fbec67679a34e0ed10616d105d6565817340d35c
MD5 79ba6b3e0c7bd144062fa96b240d733f
BLAKE2b-256 33f0cc1f2264a444e5011e6045cf58630c7358f8a18f391bd86bd2400d3767be

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ec8c3af24f0149bfef4c9bf98f7f01d5a60e7278d2ca38f64ca75e0d5466a757
MD5 520f8c3833d31ca9642386ccf4600ca7
BLAKE2b-256 d835bfc9b65726bb385b2dd206855700c55262d72014ec0621dd640cb1dd7da0

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9bbb5928f27f0fbb7d4ad6b8150f9947ddf50beb2d30e75902a0d03f08d7d328
MD5 7e7db8207d35222588d7006d45027eca
BLAKE2b-256 a3012aa6ebd216fbbfd4369db808742e63f0f5d7f27844b8c9c382e0ab5c9089

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp311-cp311-win32.whl.

File metadata

  • Download URL: configcrunch-2.1.1-cp311-cp311-win32.whl
  • Upload date:
  • Size: 847.4 kB
  • Tags: CPython 3.11, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configcrunch-2.1.1-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 50b4f4bffd9c9add15da9f60d3cc3eb605db86a92a80251947d086496c49999d
MD5 8e0bff304f3608c8a967663ceb1b52b7
BLAKE2b-256 74dc52ca0e6c3cda01e28170a081f8ced5f02ba2ad096f2d5a9503d5c3ac69d7

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9300b2d8b5c8628d1ee50ceaa0ad6460e60813b16adb9c9d00f457e02a00d3ee
MD5 b74c27bfd652a87404aeec476875181a
BLAKE2b-256 f2aa85ba585feb58ac5ee25f91e483409718b063398290bdbf7401a56ecfbd2d

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2bf588adbabda27e9294d4520835d53883a6b221b489de352ed28ef6fb81231b
MD5 86994509fb55293c75de240411bc3626
BLAKE2b-256 529fed8416335297e9a16077e99d3047ccf23c73067bcb1001b07ba9fcbbdbec

See more details on using hashes here.

File details

Details for the file configcrunch-2.1.1-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for configcrunch-2.1.1-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 611253f0572bdf05e75532c68e5a609b7c5946129846c0b92f32562bb5fc460b
MD5 799b6605b5a3c20fb093a4be391fcf61
BLAKE2b-256 7f01496ca9de13a835e4767777ebfb157fe896622fc3f50aad163bd439c8cad7

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