core: management of _list and _dict in sat.conf
This commit is contained in:
parent
f7efb167c8
commit
4b662563c9
1 changed files with 13 additions and 4 deletions
|
|
@ -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"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue