]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/config.py
Docs: Update TODO
[m_librarian.git] / m_librarian / config.py
index cbf76b7aab2c8e168ae734d6b09f8055519c181d..a6b88f01091dc0539053089c72d3aed2bb1f0e8b 100755 (executable)
@@ -29,11 +29,11 @@ def find_config_dirs():
     return None
 
 
-def find_config_file(config_dirs=None):
+def find_config_file(config_dirs=None, config_filename='m_librarian.conf'):
     if config_dirs is None:
         config_dirs = find_config_dirs()
     for d in config_dirs:
-        ml_conf_file = os.path.join(d, 'm_librarian.conf')
+        ml_conf_file = os.path.join(d, config_filename)
         if os.path.exists(ml_conf_file):
             return ml_conf_file
     else:
@@ -63,6 +63,18 @@ class ConfigWrapper(object):
             return default
         # Do not catch ValueError here, it must be propagated
 
+    def getlist(self, section, option, default=None, sep=None):
+        value = self.get(section, option)
+        if not value:
+            if default is None:
+                return []
+            return default
+        return value.split(sep)
+
+    def getpath(self, section, option, default=os.path.curdir):
+        path = self.get(section, option, default=default)
+        return os.path.expanduser(os.path.expandvars(path))
+
 
 def get_config(config_path=None):
     global _ml_config