Manage your app configuration using env variables
Project description
Envia
Did you ever lose track of all environment variables you can use to configure a project? Envia is a simple utility that allows you to group them together.
Installation
pip install envia
Usage
You can use Envia as follows
# app/config.py
from envia import EnvVar
APP_DB_VENDOR = EnvVar("APP_DB_VENDOR", default="postgres")
APP_DB_PORT = EnvVar("APP_DB_PORT", default="5432")
APP_DB_HOST = EnvVar("APP_DB_HOST")
# require() can be used to ensure early failure.
# This fails if APP_REQUIRED_VAR is not set
APP_REQUIRED_VAR = EnvVar("APP_REQUIRED_VAR").require()
To use the environment values you can do
# app/db.py
import app.config as cfg
def connect():
vendor = cfg.APP_DB_VENDOR.get_required()
port = cfg.APP_DB_PORT.get_required()
# This fails APP_DB_HOST is not set
host = cfg.APP_DB_HOST.get_required()
# This returns None if APP_DB_HOST is not set
host = cfg.APP_DB_HOST.require()
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
envia-0.0.1.tar.gz
(4.5 kB
view details)
Built Distribution
envia-0.0.1-py3-none-any.whl
(5.0 kB
view details)
File details
Details for the file envia-0.0.1.tar.gz
.
File metadata
- Download URL: envia-0.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0563a60f94f7a43f5e7f0fbf16e985d5971892af2dc84a8040c05ec455c96eb6 |
|
MD5 | 0d26074a27547ce7a5b629088f4478d3 |
|
BLAKE2b-256 | 3513ba699658f21ca1c6fa1a09e922718533e5910d50c8d7258da251ab29f6d9 |
File details
Details for the file envia-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: envia-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21be6184c853e4c73ae7db041c1f6342cf52a4ecfe96ec9c3a0e464b863b528c |
|
MD5 | bcd8fd46383580a976100e10a2b99e5c |
|
BLAKE2b-256 | 5ede8f7a86722f038bcf4ab188d3232517bbcadc1d8372a626a5e59e51f2758e |