changeset 1833:a123e881f9e5

core (config): _dict values are now handled with json syntax
author Goffi <goffi@goffi.org>
date Sat, 23 Jan 2016 20:06:01 +0100
parents 39545dc527a1
children 6209de5e3e25
files src/tools/config.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/config.py	Sat Jan 23 20:04:28 2016 +0100
+++ b/src/tools/config.py	Sat Jan 23 20:06:01 2016 +0100
@@ -30,6 +30,7 @@
 from xdg import BaseDirectory
 import os
 import csv
+import json
 
 
 def fixConfigOption(section, option, value, silent=True):
@@ -94,6 +95,7 @@
     elif name.endswith('_list'):
         value = csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next()
     elif name.endswith('_dict'):
-        value = dict(csv.reader([item], delimiter=':', quotechar='"', skipinitialspace=True).next()
-                     for item in csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next())
+        value = json.loads(value)
+        if not isinstance(value, dict):
+            raise ValueError(u"{name} value is not a dict: {value}".format(name=name, value=value))
     return value