confdaora
Project description
confdaora
Configurations using python annotations
Documentation: https://dutradda.github.io/confdaora
Source Code: https://github.com/dutradda/confdaora
Key Features
- Generate a
DictDaora
with values parsed from environment variables.
Requirements
- Python 3.8+
- 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 dataclasses import dataclass
from typing import List
from confdaora import confdaora_env
@dataclass
class DBConfig:
__prefix__ = 'db'
host: str
port: int = 3306
@dataclass
class KeyConfig:
__prefix__ = 'keys'
name: str
values: List[int]
@dataclass
class AppConfig:
db: DBConfig
keys: List[KeyConfig]
host: str
port: int = 8080
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
{'db': {'host': 'localhost', 'port': 3306}, 'keys': [{'name': 'test', 'values': [10, 20]}, {'name': 'test2', 'values': [30, 40]}], 'host': 'localhost', 'port': 8080}
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.1.7.tar.gz
(18.4 kB
view hashes)
Built Distribution
Close
Hashes for confdaora-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22708ea50fa6358c4300684ce79d79dd233c04fd94f953c0384accc04e9c441c |
|
MD5 | 27614e00938e8a31c0fbf961e5f39b5e |
|
BLAKE2b-256 | f3a0d6b42bdd8ff6a8df7f8764a6d5f85ee262bd030752a1dafc14a09daffd8e |