changeset 2451:d1153ce68ca0

tools (config): complexe data can now be set using json and the "_json" suffix
author Goffi <goffi@goffi.org>
date Thu, 30 Nov 2017 20:53:47 +0100
parents 124f5db998f2
children 7aa863cbc47f
files src/tools/config.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/config.py	Thu Nov 30 20:52:33 2017 +0100
+++ b/src/tools/config.py	Thu Nov 30 20:53:47 2017 +0100
@@ -111,4 +111,9 @@
             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