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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file configprops-1.5.1.tar.gz.
File metadata
- Download URL: configprops-1.5.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b4758cebfcec780b0087cdabbdcb736a95a3834013608e6bd8398b748ae9b34
|
|
| MD5 |
e24309d1b3c68319c5102238f0938599
|
|
| BLAKE2b-256 |
7e4e95810adf1ad3680ea80f6dabbe6809618d5d54b0b234e855116687b04e0f
|
File details
Details for the file configprops-1.5.1-py3-none-any.whl.
File metadata
- Download URL: configprops-1.5.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25b373479d30627fd523b73bf4de0b320fa3295129deb35f8878c6564c66e4e8
|
|
| MD5 |
6a2cd445c1976c3ef4009dc622bb9929
|
|
| BLAKE2b-256 |
d6dbbb1557c57749dda1f61e32b34f18f7939d9e28b02bb1344680cb652a97a1
|