tools (config): complexe data can now be set using json and the "_json" suffix

This commit is contained in:
Goffi 2017-11-30 20:53:47 +01:00
commit a01bec718e

View file

@ -111,4 +111,9 @@ def getConfig(config, section, name, default=None):
raise exceptions.ParsingError(u"Error while parsing data: {}".format(e))
if not isinstance(value, dict):
raise exceptions.ParsingError(u"{name} value is not a dict: {value}".format(name=name, value=value))
elif name.endswith('_json'):
try:
value = json.loads(value)
except ValueError as e:
raise exceptions.ParsingError(u"Error while parsing data: {}".format(e))
return value