Yaml configuration library for python
Project description
Coyaml
Coyaml is an intuitive Python library designed to simplify YAML configuration management. It lets you split your configurations into smaller files, embed environment variables, and reuse configuration nodes—keeping your settings organized, maintainable, and scalable.
Developed with practical insights from real-world projects, Coyaml is ideal for Python developers who require flexible, powerful, and simple configuration handling.
Documentation: https://coyaml.readthedocs.io
Source Code: https://github.com/kuruhuru/coyaml
Why Use Coyaml?
Coyaml simplifies common YAML management tasks:
- Dot Notation Access: Easily access nested configuration (
config.section.option). - Pydantic Integration: Automatic validation and type safety for your settings.
- Environment Variables: Direct integration of OS or
.envvariables, with defaults. - External File & YAML Inclusion: Embed file contents and additional YAML files seamlessly.
- Reusable Nodes: Reference and reuse YAML configuration sections dynamically.
Quick Start
Install Coyaml:
pip install coyaml
Load and resolve YAML configurations:
from coyaml import YConfig
config = (
YConfig()
.add_yaml_source('config.yaml')
.add_env_source()
)
config.resolve_templates() # is necessary only when using template placeholders within the YAML configuration.
Example YAML Configuration
debug:
db:
url: "postgres://user:password@localhost/dbname"
user: ${{ env:DB_USER }}
password: ${{ env:DB_PASSWORD:strong:/-password }}
init_script: ${{ file:tests/config/init.sql }}
llm: "path/to/llm/config"
index: 9
stream: true
app:
db_url: "postgresql://${{ config:debug.db.user }}:${{ config:debug.db.password }}@localhost:5432/app_db"
extra_settings: ${{ yaml:tests/config/extra.yaml }}
Using Configurations in Code
# Access nested configuration
print(config.debug.db.url)
# Access environment variables with defaults
print(config.debug.db.password)
# Access embedded file content
print(config.debug.db.init_script)
# Access YAML-included configurations
print(config.app.extra_settings)
# Modify configuration dynamically
config.index = 10
# Validate configuration via Pydantic
from pydantic import BaseModel
class AppConfig(BaseModel):
db_url: str
extra_settings: dict
app_config = config.app.to(AppConfig)
print(app_config)
Coyaml resolves references automatically, ensuring your configurations remain consistent and adaptable.
For detailed documentation, more examples, and a complete API reference, visit Coyaml Documentation.
License: Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coyaml-0.9.2.tar.gz.
File metadata
- Download URL: coyaml-0.9.2.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1abf8a13764916ca197c4917a282251d689acb2beb0866f6a5ed352a1ec9effc
|
|
| MD5 |
83775c01d5501dae8b7f4847858e5f73
|
|
| BLAKE2b-256 |
86410f09522056c3cc0e3568b04d0a95d31361aa786277e8bd021157c2592aec
|
File details
Details for the file coyaml-0.9.2-py3-none-any.whl.
File metadata
- Download URL: coyaml-0.9.2-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d815fe1c47e04954c7b5fcb804cfe51a7a6c7b20905082226bae498ca98ac90
|
|
| MD5 |
bd4602ea8cb17a5b499716f698830fe0
|
|
| BLAKE2b-256 |
d9ab7bdc815b2b25cdddc5e04c8a28b70790dbbb20f0edea4bdb2db88a589af6
|