Skip to main content

confdaora

Project description

confdaora

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

AppConfig(db=DBConfig(host='localhost', port=3306), keys=[KeyConfig0(name='test', values=[10, 20]), KeyConfig1(name='test2', values=[30, 40])], host='localhost', port=8080)

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

confdaora-0.2.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

confdaora-0.2.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file confdaora-0.2.1.tar.gz.

File metadata

  • Download URL: confdaora-0.2.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for confdaora-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c0e8d8a201c6c8a57bbc99c42e509a7fcd0188950e656732b00c2317ba177577
MD5 ce5f780fe222051846f14cf5d5d05e46
BLAKE2b-256 3e0ae5df010e7cd7295bcfd926fefba3a2a8d18c86557179de0fc5d3595e50a2

See more details on using hashes here.

File details

Details for the file confdaora-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: confdaora-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for confdaora-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9dfe5ff40120355f9a116672530ad909fb3cfd6a5db8d0c947dde5491b74f529
MD5 4859020962800ca151cf5972a2e6064a
BLAKE2b-256 810012a73cf7175a0e70f6fd426f8c90a15fedade6b0e0daec68a06c8807a06b

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