# HG changeset patch # User Goffi # Date 1386806779 -3600 # Node ID 8f50a00797692ccb2b27630928286d22f2d83d4f # Parent e07afabc4a25fce28ebcfc3d63b180430840a426 core: management of _list and _dict in sat.conf diff -r e07afabc4a25 -r 8f50a0079769 src/memory/memory.py --- a/src/memory/memory.py Tue Dec 10 17:25:31 2013 +0100 +++ b/src/memory/memory.py Thu Dec 12 01:06:19 2013 +0100 @@ -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 @@ 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"""