okfn/dpm — Issue #32: Read, Set and Delete config options
Author: dgraziotin
Created: 2011-11-13 18:05:02+00:00
State: open
Labels: lib

Assuming that dpm configuration file is never renamed and always stays in the same folder,
we need helper functions to get and set config values of dpm without directly manipulating the config object.
The set and delete functions also make the modifications persistent.

# Read the config sections and and options
* function: ```lib.get_config(section=None,option=None)```
* usage:
* ```lib.get_config()``` returns config.sections(), e.g. ```['dpm', 'index:ckan', 'index:db', 'upload:ckan']```
* ```lib.get_config(section='index:ckan')``` returns config.items('index:ckan') _without_ their values, e.g. ```['ckan.url', 'ckan.api_key']```
* ```lib.get_config(section="index.ckan",option="ckan.url")``` returns config.get('index:ckan','ckan.url'), in a list, e.g. ```['http://thedatahub.org/api/']``` rationale: same return type is more elegant

# Set the config option's value
* function:```lib.set_config(section,option,value=None)```
* usage:
* ```lib.set_config("index.ckan","ckan.api","1234567890")``` overwrites the option value for ckan.api _and_ saves the file
* ```lib.set_config("datadeck","config.file","/home/test/.datadeck")``` creates section and option if not present and sets the value. It saves the configuration file
* ```lib.set_config("datadeck","config.file", None)``` creates section and option if not present and sets the value. Overwrites the already existing value otherwise. It saves the configuration file. The third argument may be omitted or expressed as an empty string.

# Delete the config option's value
* function: ```lib.delete_config(section,option)```
* It works by calling ```lib.set_config(section,option,None)```

We should not permit a real deletion of an option or of an entire section.