config-utils

A python script that parses a simple configuration file


Keywords
configuration, file, parser
License
Other
Install
pip install config-utils==0.3

Documentation

A simply python file that can either be used separately in each project you are working on or it can easily be dumped in your main python bin to always be accessible by:

import ConfigParser

Programmatically using it is quite simply it creates a Python Object that contains all the necessary information of your config file and you can specify the different options you want. The script works as a 'variable' - 'value' pair. To programmatically 'read-in' a config file use it as:

config_file = ConfigUtils.ReadConfig(name_of_config_file, *args)

Where:
	name_of_config_file - Self explanitory
	*args -
		list of 'variables' you require from your config file.

Below is an example script 

###### config.txt #####

# this is a comment
int = 1
float = 2.0
bool = True
string = hello


##### example.py ####
import ConfigParser

config = ReadConfig('config.txt',
                    'int',
                    'float',
                    'bool',
                    'string')

values = config.options_from_config # dictionary of 'variable : value' pairs

In[1]: values
 Out[1]: {'int': 1', 'float' : '2.0', 'bool' : 'True', 'string' : 'hello'}