Skip to main content

This package provides a configuration base class to be extended with list of KEYS (same prefix) that could be overridden by environment variables.

Project description

configprops

Introduction

This package provides a configuration base class to be extended with list of KEYS (same prefix) that could be overridden by environment variables.

API

class ConfigurationProperties(key_name_prefix:str, dot_env:bool=False, debug=False):
 ...

flag dot_env means loading .env file.

Examples

#!/usr/bin/env python3

from configprops import ConfigurationProperties
import os


class AppTestConfig(ConfigurationProperties):
    TEST_APP_CONFIG_KEY_TEXT = 'Original'
    TEST_APP_CONFIG_KEY_BOOL = True
    TEST_APP_CONFIG_KEY_INT = 32
    TEST_APP_CONFIG_KEY_FLOAT = 3.3
    TEST_APP_CONFIG_KEY_OTHER = 55


def test_override():
    os.environ['TEST_APP_CONFIG_KEY_BOOL'] = '0'
    os.environ['TEST_APP_CONFIG_KEY_FLOAT'] = '8.5'
    os.environ['TEST_APP_CONFIG_KEY_INT'] = '185'

    config = AppTestConfig('TEST_APP_CONFIG_')

    assert config.TEST_APP_CONFIG_KEY_BOOL == False
    assert config.TEST_APP_CONFIG_KEY_OTHER == 55
    assert config.TEST_APP_CONFIG_KEY_FLOAT == 8.5
    assert config.TEST_APP_CONFIG_KEY_INT == 185

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

configprops-1.5.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

configprops-1.5.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file configprops-1.5.0.tar.gz.

File metadata

  • Download URL: configprops-1.5.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Darwin/20.3.0

File hashes

Hashes for configprops-1.5.0.tar.gz
Algorithm Hash digest
SHA256 3858906c05b4c0c9126c6ac949d427905626e1332797c749175ffed9321bd376
MD5 d161d1ecf82e25d4f9220e8f74fb0372
BLAKE2b-256 46fe82ac0d85d8db40f6812ed81820cef886ff77b295369278b2405bb4dd7b52

See more details on using hashes here.

File details

Details for the file configprops-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: configprops-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.9.2 Darwin/20.3.0

File hashes

Hashes for configprops-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cae0c606496c4e7254aaae9ab322fd21cba426d262006d59de7fe5855ece5d5a
MD5 1602eec4ec7d31d4533f0a70783d5d66
BLAKE2b-256 a282aed7f2502973702fde077784ac21501ae996a00fbb3f67a47c714f5712a4

See more details on using hashes here.

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