From a01bec718ea6e1dcfb0b885d836dc524c060cee3 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 30 Nov 2017 20:53:47 +0100 Subject: [PATCH] tools (config): complexe data can now be set using json and the "_json" suffix --- src/tools/config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/config.py b/src/tools/config.py index 3e2c5f33..4b97f6ac 100644 --- a/src/tools/config.py +++ b/src/tools/config.py @@ -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