From: Oleg Broytman Date: Sun, 10 Jun 2018 22:16:24 +0000 (+0300) Subject: Feat(config): getlist X-Git-Tag: 0.1.4~11 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=18f8a04ae9135d026a4db5548f80b00e40b763e0;p=m_librarian.git Feat(config): getlist --- 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)