kumistatus/setuptools/__init__.py
2016-07-20 19:30:51 +02:00

25 lines
659 B
Python

import ast, configparser
conffile = "config.cfg"
class SetupException(Exception):
def __str__(self):
return "Seems like config.cfg has not been created yet. Run setup.py to do so."
def getSetting(section, setting, exception = False):
try:
config = configparser.RawConfigParser()
config.read(conffile)
return config.get(section, setting)
except:
if exception:
raise SetupException()
return None
def getListSetting(section, setting, exception = False):
config = configparser.RawConfigParser()
config.read(conffile)
lit = config.get(section, setting)
if lit == None and exception:
raise SetupException()
return ast.literal_eval(lit)