confdaora
Project description
confdaora
Configurations using python annotations
Key Features
- Generate a
DictDaora
with values parsed from environment variables.
Requirements
- Python 3.6+
- dictdaora
- jsondaora
Instalation
$ pip install confdaora
Basic example
from typing import TypedDict
from confdaora import confdaora_env
class AppConfig(TypedDict):
port: int
host: str
config = confdaora_env(AppConfig)
print(config)
Suposing your file calls myconf.py
:
PORT=8080 HOST=localhost python myconf.py
{'port': 8080, 'host': 'localhost'}
Complex example
from typing import List, TypedDict
from confdaora import confdaora_env
class DBConfig(TypedDict):
__prefix__ = 'db'
port: int = 3306
host: str
KeyConfig = TypedDict('KeyConfig', {'name': str, 'values': List[int]})
KeyConfig.__prefix__ = 'keys'
class AppConfig(TypedDict):
port: int = 8080
host: str
db: DBConfig
keys: List[KeyConfig]
config = confdaora_env(AppConfig)
print(config)
Suposing your file calls myconf.py
:
HOST=localhost \
DB_HOST=localhost \
KEYS_0_NAME=test \
KEYS_0_VALUES=10,20 \
KEYS_1_NAME=test2 \
KEYS_1_VALUES=30,40 \
python myconf.py
{'port': 8080, 'host': 'localhost', 'db': {'port': 3306, 'host': 'localhost'}, 'keys': [{'name': 'test', 'values': [10, 20]}, {'name': 'test2', 'values': [30, 40]}]}
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
confdaora-0.0.2.tar.gz
(14.6 kB
view hashes)
Built Distribution
confdaora-0.0.2-py3-none-any.whl
(10.1 kB
view hashes)
Close
Hashes for confdaora-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dcd6c5bfe23462bf8709e92eab5dbca439353056196dfe86a580b43d0fcb643 |
|
MD5 | 49863f23c5cef06fa4058572b60a2d35 |
|
BLAKE2b-256 | b2241e3c74c149fada81fb809305509bf6c253be4d6e6981023412127ecfa5ef |