diff options
Diffstat (limited to 'searx/answerers/__init__.py')
-rw-r--r-- | searx/answerers/__init__.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/searx/answerers/__init__.py b/searx/answerers/__init__.py index 8e2b9b35a..346bbb085 100644 --- a/searx/answerers/__init__.py +++ b/searx/answerers/__init__.py @@ -1,25 +1,30 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# pylint: disable=missing-module-docstring + +import sys from os import listdir from os.path import realpath, dirname, join, isdir -from searx.utils import load_module from collections import defaultdict +from searx.utils import load_module answerers_dir = dirname(realpath(__file__)) def load_answerers(): - answerers = [] + answerers = [] # pylint: disable=redefined-outer-name + for filename in listdir(answerers_dir): if not isdir(join(answerers_dir, filename)) or filename.startswith('_'): continue module = load_module('answerer.py', join(answerers_dir, filename)) - if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not len(module.keywords): - exit(2) + if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not module.keywords: + sys.exit(2) answerers.append(module) return answerers -def get_answerers_by_keywords(answerers): +def get_answerers_by_keywords(answerers): # pylint:disable=redefined-outer-name by_keyword = defaultdict(list) for answerer in answerers: for keyword in answerer.keywords: |