summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-09-21 12:19:36 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-09-21 12:19:36 +0100
commit75a73b7182a7e5b2cc14331503c110591e6571e4 (patch)
tree6daff675afdb178578db9437411da88836eddb76
parent038ef94e3b58484e3907f982ed2748e8936f37c3 (diff)
downloadpykolab-75a73b7182a7e5b2cc14331503c110591e6571e4.tar.gz
Add conf.get_list() function to retrieve a python list from a comma and/or space seperated list
-rw-r--r--pykolab/conf/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pykolab/conf/__init__.py b/pykolab/conf/__init__.py
index 295cd52..e9eaad3 100644
--- a/pykolab/conf/__init__.py
+++ b/pykolab/conf/__init__.py
@@ -439,6 +439,26 @@ class Conf(object):
def has_option(self, section, option):
return self.cfg_parser.has_option(section, option)
+ def get_list(self, section, key):
+ """
+ Gets a comma and/or space seperated list from the configuration file
+ and returns a list.
+ """
+ values = []
+ untrimmed_values = []
+
+ setting = self.get_raw(section, key)
+ raw_values = setting.split(',')
+
+ for raw_value in raw_values:
+ untrimmed_values.extend(raw_value.split(' '))
+
+ for value in untrimmed_values:
+ if not value.strip() == "":
+ values.append(value.strip().lower())
+
+ return values
+
def get_raw(self, section, key):
if not self.cfg_parser:
self.read_config()