From 18f8a04ae9135d026a4db5548f80b00e40b763e0 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 11 Jun 2018 01:16:24 +0300 Subject: [PATCH] Feat(config): getlist --- m_librarian/config.py | 8 ++++++++ m_librarian/search.py | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/m_librarian/config.py b/m_librarian/config.py index 9fff407..b4a7b60 100755 --- a/m_librarian/config.py +++ b/m_librarian/config.py @@ -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)) diff --git a/m_librarian/search.py b/m_librarian/search.py index e4e2884..82889a8 100644 --- a/m_librarian/search.py +++ b/m_librarian/search.py @@ -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) -- 2.39.5