Skip to main content

Simple method used to load configuration variables from different sources.

Project description

Build Status - master branch Coverage of the code quality License

Simple method used to load configuration variables from different sources.

Supports loadings variables from the environment, json file and/or Django settings.

The method will search for the keys in any of the 3 sources and returns the first match.

Search order:

  1. Environment

  2. JSON - used if path is set and the file exists

  3. Django settings - used if Django is installed

This is useful if you need to set configuration variables(SECRET_KEY, DATABASE_NAME, etc…) via environment on a CI server and load the same variables from a json file in a production environment.

Installation

pip install iconf (or add to your requirements.txt)

Usage

import iconf

# find and return keys from environment variables and/or django settings
# and/or json file
configs = iconf.get(keys=["KEY1", "KEY2"], path="configs.json")


# import full json file
configs = iconf.get(path="configs.json")

# import from environment and/or django settings
configs = iconf.get(["KEY1", "KEY2"])

Test

run tests with python -m unittest discover

License

3 Clause BSD.

Bug report and Help

For bug reports open a github ticket. Patches gratefully accepted.

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

iconf-0.0.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

iconf-0.0.2-py3.7.egg (3.4 kB view hashes)

Uploaded Source

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