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
envawareconfig-0.2.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for envawareconfig-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa2a85a83d0f4f1e6e67de7f96a7c08a32575c3497e371044cb9c9fb8b5d8ab |
|
MD5 | f302874a7d0c13fbf50bc3760d3b4e76 |
|
BLAKE2b-256 | b407acd5a3a79281ea09583d925b8a4e83a74d875a6786776947e04b7b3a43b1 |