Showing posts with label YAML. Show all posts
Showing posts with label YAML. Show all posts

Thursday, July 11, 2013

kaptan, multi-format configuration file manager for Python


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.py
Output:
--------------------------------------------------
environment: DEV
redis_uri: redis://localhost:6379/0
pagination.limit: 20
--------------------------------------------------
pagination: {'per_page': 10, 'limit': 20}
--------------------------------------------------

- Vasudev Ram - Dancing Bison Enterprises

Contact me

Tuesday, October 23, 2012

YAML site eats its own dog food :)


By Vasudev Ram

Just noticed that the YAML web site eats its own dog food
:) Cool. I had used YAML (Wikipedia link) sometime earlier when working on Ruby and Ruby on Rails. (Rails used YAML then and may still do.)

- Vasudev Ram - Dancing Bison Enterprises


Python Auto Reloader, watchdog and argh


By Vasudev Ram

PythonAR (Python Auto Reloader) is an "app reloader" for Python apps. It reloads your app when the source files change (something like what the Tomcat server does for Java web apps, and other such tools also do).

PythonAr is by tshirtman, a developer who seems to be involved with Kivy, a cross-platform Python GUI toolkit for desktop and mobile, which I blogged about recently

It uses the watchdog Python library, which in turn uses argh, a simple wrapper for argparse.

The watchdog library also uses PyYAML, a Python library for handling YAML, and pathtools.


- Vasudev Ram - Dancing Bison Enterprises