Simple method used to load configuration variables from different sources.
Project description
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:
Environment
JSON - used if path is set and the file exists
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
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.