Skip to main content

Utilities for building applications

Project description

pipeline status coverage report

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


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)

Uploaded Source

Built Distribution

datek_app_utils-0.2.0-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page