core (config): _dict values are now handled with json syntax
This commit is contained in:
parent
d1fed06699
commit
c5d6e545f5
1 changed files with 4 additions and 2 deletions
|
|
@ -30,6 +30,7 @@ from ConfigParser import SafeConfigParser, DEFAULTSECT, NoOptionError, NoSection
|
|||
from xdg import BaseDirectory
|
||||
import os
|
||||
import csv
|
||||
import json
|
||||
|
||||
|
||||
def fixConfigOption(section, option, value, silent=True):
|
||||
|
|
@ -94,6 +95,7 @@ def getConfig(config, section, name, default=None):
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue