Utilities for building applications
Project description
Utilities for building applications.
Contains:
- Config loading from environment
- Bootstrap for logging
Examples:
import os
from datek_app_utils.env_config.base import BaseConfig
os.environ["COLOR"] = "RED"
os.environ["TEMPERATURE"] = "50"
class Config(BaseConfig):
COLOR: str
TEMPERATURE: int
assert Config.COLOR == "RED"
assert Config.TEMPERATURE == 50
The Config
class casts the values automatically.
Moreover, you can test whether all the mandatory variables have been set or not.
import os
from datek_app_utils.env_config.base import BaseConfig
from datek_app_utils.env_config.utils import validate_config
from datek_app_utils.env_config.errors import ValidationError
os.environ["COLOR"] = "RED"
class Config(BaseConfig):
COLOR: str
TEMPERATURE: int
AMOUNT: int = None
try:
validate_config(Config)
except ValidationError as error:
for attribute_error in error.errors:
print(attribute_error)
Output:
TEMPERATURE: Not set. Required type: <class 'int'>
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
datek_app_utils-0.3.2.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for datek_app_utils-0.3.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfc2e1fc93207ca7709c0c77c5b06d83a87cfd1c392a36c305eddc431e83f151 |
|
MD5 | d05baa1a596d99c584bed958e4cfe035 |
|
BLAKE2b-256 | e978d0c4c45085d4b471470f2b70208ca991486fae4f64c6c0ea9be436bd3ef3 |