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
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
configprops-1.5.1.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for configprops-1.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b373479d30627fd523b73bf4de0b320fa3295129deb35f8878c6564c66e4e8 |
|
MD5 | 6a2cd445c1976c3ef4009dc622bb9929 |
|
BLAKE2-256 | d6dbbb1557c57749dda1f61e32b34f18f7939d9e28b02bb1344680cb652a97a1 |