Mercurial > libervia-backend
diff src/tools/config.py @ 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 | 8b37a62336c3 |
children | 0046283a285d |
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