Skip to main content

Python library to parse config files that require indexing

Project description

A class to parse configuration files that require indexing.
This class returns a dictionary that you can call to retrieve items
from your config file.

To use this parser to its full potential create config files in the
following format for example:

(Example config file)

# Home server
server_1 = somename
ip_1 =
location_1 = san jose

# Remote server
server_2 = someothername
ip_2 =
location_2 = boston

# Universal configs
universal_key = something universal
my_username = kyle

You can keep raising the indexed number as much as you want.
The way to use this library is to pick a config definition
that you know will be different for each index. In this case I would
use "server" as the "defining key" and that would make each server name
into its own dictionary and the key/value pairs for it would be the config
key/values that are associated with the same index number.

There are 3 lists that are created on each parse:
keys = this is a list of the keys that are not indexed
(used for universal purposes)
index_keys = this is a list of all the keys that are indexed
(this is generated based on the defining key)
all_keys = this is a list of all the keys combined


import IndexConfigParser

(The following code will print the dictionaries of each index key)
icp = IndexConfigParser.IndexConfigParser("/home/kyle/config.cfg", "server")
for key in icp.index_keys:
print "The dictionary for %s is: " %key
print icp[key]

(The following is how to call a specific key in the index key dict)
icp = IndexConfigParser.IndexConfigParser("/home/kyle/config.cfg", "server")
var = "somename"
(Using the example config file above this would return "")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for IndexConfigParser, version 1.2
Filename, size File type Python version Upload date Hashes
Filename, size IndexConfigParser-1.2.tar.gz (2.0 kB) File type Dumb Binary Python version any Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page