]> git.phdru.name Git - m_librarian.git/commitdiff
Feat(config): getlist
authorOleg Broytman <phd@phdru.name>
Sun, 10 Jun 2018 22:16:24 +0000 (01:16 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 10 Jun 2018 23:31:08 +0000 (02:31 +0300)
m_librarian/config.py
m_librarian/search.py

index 9fff40781d63a58db98004704c0c2aa6deeac1d0..b4a7b603d23d0fe06c4c693fb5081f0b29f9b6ad 100755 (executable)
@@ -63,6 +63,14 @@ 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))
index e4e2884c2c7d5a61642fb7324e7f55cd4db30fdd..82889a8d518e720108d3dc297316a4409c080a69 100644 (file)
@@ -75,13 +75,13 @@ def search_books(search_type, case_sensitive, values, join_expressions=None,
                  orderBy=None, use_filters=False):
     if use_filters:
         config = get_config()
-        lang_filter = config.get('filters', 'lang')
+        lang_filter = config.getlist('filters', 'lang')
         deleted_filter = config.getint('filters', 'deleted')
         if lang_filter:
             if join_expressions is None:
                 join_expressions = []
             lang_conditions = []
-            for lang in lang_filter.split():
+            for lang in lang_filter:
                 lvalues = {'name': lang}
                 conditions = mk_search_conditions(
                     Language, search_type, case_sensitive, lvalues)