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.2.tar.gz
(4.5 kB
view details)
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
envia-0.0.2-py3-none-any.whl
(5.1 kB
view details)
File details
Details for the file envia-0.0.2.tar.gz.
File metadata
- Download URL: envia-0.0.2.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 |
4d2b5c18462f8000946a07285c48f9450e2369a6f1a94f1f405a523ac3379e45
|
|
| MD5 |
7e5d708d0480505de613ee7b62d2c481
|
|
| BLAKE2b-256 |
38fef64b7acbab24178090ab31fc9fc2a191f0c7e9306f54a30dd7965ab5e0f6
|
File details
Details for the file envia-0.0.2-py3-none-any.whl.
File metadata
- Download URL: envia-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.1 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 |
8b62a44d78b069616a49877fea5f103d449769b48269562f28dc4438fcda41a2
|
|
| MD5 |
17295044904ca74bb478152b7022be71
|
|
| BLAKE2b-256 |
989f93f5b4b5aa4024278a96c2f57cbb4dffe37ec051931b095ecdf837963ed3
|