Load configurations from yaml files with automatic environment variable substitution
Project description
Envawareconfig
Load configurations from yaml files with automatic environment variable substitution.
Installation
with pip:
pip install envawareconfig
with poetry:
poetry add envawareconfig
QuickStart
Suppose you have a configuration file like this:
# test-config.yaml
database:
name: my-database
user: "${DB_USER:admin}"
password: "${DB_PASSWORD}"
and that you have set the environment variable DB_PASSWORD to my-secret-password
while DB_USER has been left unset.
then running the following code:
# main.py
from envawareconfig import load_config
config = load_config("tests/test-config.yaml")
would result in:
config = {
"database": {
"name": "my-database",
"user": "admin",
"password": "my-secret-password"
}
}
Notice that ${DB_PASSWORD} has been expanded and ${DB_USER:admin} used the default value.
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 envawareconfig-0.2.1.tar.gz.
File metadata
- Download URL: envawareconfig-0.2.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.4.0-121-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5932a9c4d74c3e1e805914979f40bc5f557613d8216bfc7a5ccde5266fdf835e
|
|
| MD5 |
467d9e293d4c9dac936850ee096d2c5a
|
|
| BLAKE2b-256 |
aaa217da34b1b07f3bf9bbb7d626072adb5cbcfda20cbd7f14e0eb4332e64422
|
File details
Details for the file envawareconfig-0.2.1-py3-none-any.whl.
File metadata
- Download URL: envawareconfig-0.2.1-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.4.0-121-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fa2a85a83d0f4f1e6e67de7f96a7c08a32575c3497e371044cb9c9fb8b5d8ab
|
|
| MD5 |
f302874a7d0c13fbf50bc3760d3b4e76
|
|
| BLAKE2b-256 |
b407acd5a3a79281ea09583d925b8a4e83a74d875a6786776947e04b7b3a43b1
|