Commit fe7de14d authored by Gerion Entrup's avatar Gerion Entrup
Browse files

add parser.py

untested
parent c1cc5baf
import configparser
def convert(settings, opt, value):
t = type(getattr(settings, opt))
try:
return t(value)
except:
return None
def parse(path, settings):
config = configparser.ConfigParser()
config.read(path)
root = 'settings'
root = config[root]
for opt, value in settings.get_options():
if opt in root:
v = convert(settings, opt, root[opt])
if v is not None and settings.check_constr(opt, v):
setattr(settings, opt, v)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment