core: management of _list and _dict in sat.conf

This commit is contained in:
Goffi 2013-12-12 01:06:19 +01:00
commit 4b662563c9

View file

@ -20,6 +20,7 @@
from __future__ import with_statement
import os.path
import csv
from ConfigParser import SafeConfigParser, NoOptionError, NoSectionError
from xml.dom import minidom
from logging import debug, info, warning, error
@ -651,11 +652,19 @@ class Memory(object):
if not section:
section = 'DEFAULT'
try:
_value = self.config.get(section, name)
value = self.config.get(section, name)
except (NoOptionError, NoSectionError):
_value = ''
value = ''
return os.path.expanduser(_value) if name.endswith('_path') or name.endswith('_dir') else _value
if name.endswith('_path') or name.endswith('_dir'):
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()
elif name.endswith('_dict'):
value = dict(csv.reader([item], delimiter=':', quotechar='"').next()
for item in csv.reader([value], delimiter=',', quotechar='"').next())
return value
def load_xml(self, filename):
"""Load parameters template from xml file"""