Skip to main content

Store your configurations for applications in JSON.

Project description

https://raw.githubusercontent.com/lk-geimfari/wasserstoff/master/media/wasserstoff_large.png.png

Wasserstoff - is a library that help you store your configurations for applications in JSON files. The configuration will be easily loaded to the scope of configuration object. The library was written with the use of tools from the standard Python library, and therefore, it does not have any side dependencies.

https://travis-ci.org/lk-geimfari/wasserstoff.svg?branch=master https://badge.fury.io/py/wasserstoff.svg https://codecov.io/gh/lk-geimfari/wasserstoff/branch/master/graph/badge.svg

Installation

➜  ~ pip install wasserstoff

or (when the project has been cloned):

➜  make test
➜  make install

Usage

Content of dev.json:

{
  "smtp server": [
    "smtp.yandex.ru",
    "smtp.gmail.com"
  ],
  "port": 456,
  "ssl": true,
  "secret_key": "SECRET_KEY_HERE"
}

Content of test.json:

{
  "ssl": false,
  "secret_key": "001110110100101100101010100010111010"
}

Loading configurations from the file:

>>> from wasserstoff import (
...     Config,
...     Environment,
... )

>>> env = Environment()

>>> dev = Config(
...     filename='dev',
...     scope='dev',
... )

>>> test = Config(
...     filename='test',
...     scope='test',
... )

>>> env.patch(dev, test)
>>> env.commit()

Now you can access to your configurations:

>>> env.dev.SMTP_SERVER
['smtp.yandex.ru', 'smtp.gmail.com']

>>> env.dev.SSL
True

>>> env.dev.PORT
456

>>> env.dev.SECRET_KEY
'SECRET_KEY_HERE'

>>> env.test.SSL
False

>>> env.test.SECRET_KEY
'001110110100101100101010100010111010'

License

Wasserstoff is licensed under the MIT License. See LICENSE for more information.

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 wasserstoff, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size wasserstoff-0.0.3.tar.gz (4.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page