Skip to content
Snippets Groups Projects
Commit f283e3cc authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Cast options correctly

parent 5f27f672
No related branches found
No related tags found
No related merge requests found
...@@ -94,12 +94,14 @@ def update_options_from_commandline(opt): ...@@ -94,12 +94,14 @@ def update_options_from_commandline(opt):
def update_options_from_inifile(opt): def update_options_from_inifile(opt):
""" Return an options array object with updated values from an inifile """ """ Return an options array object with updated values from an inifile """
if opt.ini_file: if opt.ini_file:
def _fix_bool(k, v): def _fix_types(k, v):
if hasattr(type(opt), k) and getattr(type(opt), k).type is bool: if hasattr(type(opt), k) and getattr(type(opt), k).type is bool:
return bool(eval(v)) return bool(eval(v))
if hasattr(type(opt), k):
return getattr(type(opt), k).type(v)
return v return v
ini = parse_ini_file(opt.ini_file).get("formcompiler", {}) ini = parse_ini_file(opt.ini_file).get("formcompiler", {})
ini = {k: _fix_bool(k, v) for k, v in ini.items()} ini = {k: _fix_types(k, v) for k, v in ini.items()}
opt = opt.copy(**ini) opt = opt.copy(**ini)
return opt return opt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment