summaryrefslogtreecommitdiff
path: root/searx/search/processors/__init__.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-04-27 16:50:41 +0200
committerGitHub <noreply@github.com>2021-04-27 16:50:41 +0200
commit87e914e398dc7bfad173ec870d0665a94054e644 (patch)
tree510de176eb0a3cd77c5fc78890aa6045c3d054b1 /searx/search/processors/__init__.py
parent4afe5a807578389b534f5fca9c4f70c9d388e3e2 (diff)
parent924f9afea37b6c545a03505a7ec291cf44654ca7 (diff)
downloadsearxng-87e914e398dc7bfad173ec870d0665a94054e644.tar.gz
searxng-87e914e398dc7bfad173ec870d0665a94054e644.zip
Merge pull request #28 from searxng/mod-processors-error-message
[mod] processors: show identical error messages on /search and /stats
Diffstat (limited to 'searx/search/processors/__init__.py')
-rw-r--r--searx/search/processors/__init__.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/searx/search/processors/__init__.py b/searx/search/processors/__init__.py
index 4cae3cd0f..caac74e65 100644
--- a/searx/search/processors/__init__.py
+++ b/searx/search/processors/__init__.py
@@ -1,37 +1,49 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# lint: pylint
+
+"""Implement request processores used by engine-types.
+
+"""
+
+__all__ = [
+ 'EngineProcessor',
+ 'OfflineProcessor',
+ 'OnlineProcessor',
+ 'OnlineDictionaryProcessor',
+ 'OnlineCurrencyProcessor',
+ 'processors',
+]
+
+from searx import logger
+import searx.engines as engines
from .online import OnlineProcessor
from .offline import OfflineProcessor
from .online_dictionary import OnlineDictionaryProcessor
from .online_currency import OnlineCurrencyProcessor
from .abstract import EngineProcessor
-from searx import logger
-import searx.engines as engines
-
-__all__ = ['EngineProcessor', 'OfflineProcessor', 'OnlineProcessor',
- 'OnlineDictionaryProcessor', 'OnlineCurrencyProcessor', 'processors']
logger = logger.getChild('search.processors')
processors = {}
-
+"""Cache request processores, stored by *engine-name* (:py:func:`initialize`)"""
def get_processor_class(engine_type):
+ """Return processor class according to the ``engine_type``"""
for c in [OnlineProcessor, OfflineProcessor, OnlineDictionaryProcessor, OnlineCurrencyProcessor]:
if c.engine_type == engine_type:
return c
return None
-
def get_processor(engine, engine_name):
+ """Return processor instance that fits to ``engine.engine.type``)"""
engine_type = getattr(engine, 'engine_type', 'online')
processor_class = get_processor_class(engine_type)
if processor_class:
return processor_class(engine, engine_name)
- else:
- return None
-
+ return None
def initialize(engine_list):
+ """Initialize all engines and store a processor for each engine in :py:obj:`processors`."""
engines.initialize_engines(engine_list)
for engine_name, engine in engines.engines.items():
processor = get_processor(engine, engine_name)