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.1.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for datek_app_utils-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67e8bfdc1e88fdb70175a7f08c91c8c6b8c8f8690256e2028ff19083c993270a |
|
MD5 | 5544953fb2a426eb4158a9e78ab8d7a8 |
|
BLAKE2b-256 | 21f72de175fe8c8864ffd294f22f0db4fee55b56d733391901f4329399eea6b8 |