Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Configuration parser based on YAML-Files with support for variables, overlaying and hierarchies
|build| |docs| |pypi-version| |pypi-downloads| |pypi-license| |pypi-pyversions|
.. |build| image:: https://img.shields.io/github/actions/workflow/status/theCapypara/configcrunch/build.yml :target: https://github.com/theCapypara/configcrunch/actions :alt: Build Status
.. |docs| image:: https://readthedocs.org/projects/configcrunch/badge/?version=latest :target: https://configcrunch.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. |pypi-version| image:: https://img.shields.io/pypi/v/configcrunch :target: https://pypi.org/project/configcrunch/ :alt: Version
.. |pypi-downloads| image:: https://img.shields.io/pypi/dm/configcrunch :target: https://pypi.org/project/configcrunch/ :alt: Downloads
.. |pypi-license| image:: https://img.shields.io/pypi/l/configcrunch :alt: License (MIT)
.. |pypi-pyversions| image:: https://img.shields.io/pypi/pyversions/configcrunch :alt: 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.7 and up.
Install it via pip: pip install configcrunch
Features:
Minijinja <https://github.com/mitsuhiko/minijinja>
_ templates that
can reference any other field inside the same or parent document.Used by:
Riptide <https://github.com/theCapypara/riptide-lib>
_By default Configcrunch uses schema <https://pypi.org/project/schema/>
_ to validate schemas.
But you can also use your own validation logic!
This is an example that uses most of the features described above, using two document types.
.. code-block:: yaml
# doc1.yml - Type: one
one:
name: Document
number: 1
sub:
# Sub-document of type "two"
$ref: /doc2
two_field: "{{ parent().method() }}"
.. code-block:: yaml
# <lookup path>/doc2.yml - Type: two
two:
name: Doc 2
number: 2
two_field: This is overridden
.. code-block:: python
# 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
Inside the configcrunch.tests
package are tests.
To run the tests, see run_tests.sh
.
The complete documentation can be found at Read the Docs <https://configcrunch.readthedocs.io/en/latest/>
_ (or in the docs directory).
FAQs
Configuration parser based on YAML-Files with support for variables, overlaying and hierarchies
We found that configcrunch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.