diff src/tools/config.py @ 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 d17772b0fe22
children 5b8a859d5bb4
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