Skip to main content

Configus - a declarative spec for configuration

Project description

Configus - a declarative contract for configuration

### Instalation

pip install configus

### Features

- [x] Unified spec for process config
- [x] Strict validation of config, no more trailing whitespaces or runtime panics from malphormed uri's

- [x] Support parametrization from env variables and cli arguments at the same time.
- [x] The same param could passed as `export DEBUG=on` or `--debug=on`
- [x] Auto load of `.env` file
- [x] Easy to mock for unit tests

### Usage

Let start with a simple spec that our requires `debug`, `version` and `secret_cookie` configuration params

from configus import config, trafaret as t

if __name__ == '__main__':
# Describes shape of the data params which will be taken either from env, cli args or envfile.
schema = t.Dict(DEBUG=t.StrBool, VERSION=t.Float, SECRET_COOKIE=t.String)
env_vars = config(schema=schema)
assert env_vars == {'DEBUG': True, VERSION: 0.1, SECRET_COOKIE=<......>}

Once schema defined we can pass variables throw env


Cmd flags
python --debug=1 version=1.0

Or even both

export VERSION=1.0
python --debug=2

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for configus, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size configus-0.1.4.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page