comparison src/tools/config.py @ 1445:ddc7a39ff9d1

tools (config): when reading a list or dict from the config file, ignore spaces immediately following the delimiter
author souliane <souliane@mailoo.org>
date Wed, 22 Jul 2015 11:42:37 +0200
parents 3265a2639182
children d17772b0fe22
comparison
equal deleted inserted replaced
1444:8ce9924fa92c 1445:ddc7a39ff9d1
90 90
91 if name.endswith('_path') or name.endswith('_dir'): 91 if name.endswith('_path') or name.endswith('_dir'):
92 value = os.path.expanduser(value) 92 value = os.path.expanduser(value)
93 # thx to Brian (http://stackoverflow.com/questions/186857/splitting-a-semicolon-separated-string-to-a-dictionary-in-python/186873#186873) 93 # thx to Brian (http://stackoverflow.com/questions/186857/splitting-a-semicolon-separated-string-to-a-dictionary-in-python/186873#186873)
94 elif name.endswith('_list'): 94 elif name.endswith('_list'):
95 value = csv.reader([value], delimiter=',', quotechar='"').next() 95 value = csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next()
96 elif name.endswith('_dict'): 96 elif name.endswith('_dict'):
97 value = dict(csv.reader([item], delimiter=':', quotechar='"').next() 97 value = dict(csv.reader([item], delimiter=':', quotechar='"', skipinitialspace=True).next()
98 for item in csv.reader([value], delimiter=',', quotechar='"').next()) 98 for item in csv.reader([value], delimiter=',', quotechar='"', skipinitialspace=True).next())
99 return value 99 return value