tools (config): when reading a list or dict from the config file, ignore spaces immediately following the delimiter

This commit is contained in:
souliane 2015-07-22 11:42:37 +02:00
commit eaaa5e2164

View file

@ -92,8 +92,8 @@ def getConfig(config, section, name, default=None):
value = os.path.expanduser(value)
# thx to Brian (http://stackoverflow.com/questions/186857/splitting-a-semicolon-separated-string-to-a-dictionary-in-python/186873#186873)
elif name.endswith('_list'):
value = csv.reader([value], delimiter=',', quotechar='"').next()
value = csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next()
elif name.endswith('_dict'):
value = dict(csv.reader([item], delimiter=':', quotechar='"').next()
for item in csv.reader([value], delimiter=',', quotechar='"').next())
value = dict(csv.reader([item], delimiter=':', quotechar='"', skipinitialspace=True).next()
for item in csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next())
return value