Simple YAML configuration file parser with easy access for structured data
pip install envyamlEnvYAML | Easy configuration file parser for structured data
Motivation
Modern configuration files become to be more and more complex, flexible, and readable. YAML file format is perfect to store configuration but had no option to pass environment variables. They give flexibility, readability and provide an option to store complex data structure. This project goal is to simplify usage of the YAML file and environment variables as program configuration files with easy config key access.
Install
pip install envyaml
Basic usage
Let's assume we had a project with this config file env.yaml
# env.yaml
project:
name: "${PROJECT_NAME}-${PROJECT_ID}"
database:
host: $DATABASE_HOST
port: 3301
username: username
password: $DATABASE_PASSWORD
database: test
table:
user: table_user
blog: table_blog
query: |-
SELECT * FROM "users" WHERE "user" = $1 AND "login" = $2 AND "pwd" = $3
insert: |-
INSERT INTO "{table}" (user, login) VALUES ($1, $2)
redis:
host: $REDIS_HOST|127.0.0.1
port: 5040
db: $REDIS_DB|3 # with default value
config:
expire: 300
prefix: $REDIS_PREFIX
escaped: $$.extra
empty_env: $NOT_EXIST_ENV_VARIABLE