By Vasudev Ram
Seen via Twitter.

kaptan is a Python library to manage configuration files. It looks useful and easy to use. It supports dicts, JSON, YAML and INI and Python :-) file formats.
Here is a simple program to show the use of kaptan:
# test_kaptan.py
import kaptan
config = kaptan.Kaptan()
config.import_config({
'environment': 'DEV',
'redis_uri': 'redis://localhost:6379/0',
'debug': False,
'pagination': {
'per_page': 10,
'limit': 20,
}
})
print "-" * 50
print "environment:", config.get("environment")
print "redis_uri:", config.get("redis_uri")
print "pagination.limit:", config.get("pagination.limit")
print "-" * 50
print "pagination:", config.get("pagination")
print "-" * 50
Run the above program with:
python test_kaptan.pyOutput:
--------------------------------------------------
environment: DEV
redis_uri: redis://localhost:6379/0
pagination.limit: 20
--------------------------------------------------
pagination: {'per_page': 10, 'limit': 20}
--------------------------------------------------
- Vasudev Ram - Dancing Bison Enterprises
Contact me

No comments:
Post a Comment