Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Config Parsing
import ConfigParser
import os
def ConfigSectionMap(section, Config):
dict1 = {}
options = Config.options(section)
for option in options:
dict1[option] = Config.get(section, option)
if dict1[option] == -1:
print "skip: %s" % option
print "exception on %s!" % option
dict1[option] = None
return dict1
def getConfig():
Config = ConfigParser.ConfigParser()
file = str(os.path.dirname(os.path.realpath(__file__))) + "/../../file.config"
return ConfigSectionMap(Config.sections()[0], Config)
print getConfig()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment