Utilities for building applications
Project description
Utilities for building applications.
Contains:
- Logging
- Loading config from environment variables
Config usage:
import os
from datek_app_utils.env_config 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 values are being casted if you read them. Moreover, you can test whether all of the variables have been set or not.
import os
from datek_app_utils.env_config import BaseConfig, validate_config
os.environ["COLOR"] = "RED"
class Config(BaseConfig):
COLOR: str
TEMPERATURE: int
assert not validate_config(Config)
outputs:
2021-03-05 19:03:22,023 [env_config.py:58] INFO Validating config: Config
2021-03-05 19:03:22,023 [env_config.py:62] INFO COLOR: RED
2021-03-05 19:03:22,023 [env_config.py:66] ERROR Environmental variable `TEMPERATURE` is 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.2.0.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for datek_app_utils-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 910b0664384b9c3d07ee00790785d19780905b34d30c2d4cdd47270a6083bd40 |
|
MD5 | f0f2c13927b4a34b96f8ca0c6bbce2a9 |
|
BLAKE2b-256 | d1ebe787be99581337bb7685030ee2d3cf8fed487e3c5ac40a8199179853e2ba |