Mercurial > libervia-backend
changeset 729:8f50a0079769
core: management of _list and _dict in sat.conf
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Dec 2013 01:06:19 +0100 |
parents | e07afabc4a25 |
children | 32bbabe809da |
files | src/memory/memory.py |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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"""