summaryrefslogtreecommitdiff
path: root/searx/engines/demo_offline.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2025-09-10 17:23:52 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-09-18 19:40:03 +0200
commit09fddfde24128ea119e89f6d844294c4d36e419f (patch)
tree24719bb40a05c2384a0a74fa58b5bc4fc1babe11 /searx/engines/demo_offline.py
parent8f8343dc0d78bb57215afc3e99fd9000fce6e0cf (diff)
[mod] demo engines: smaller corrections and improvements
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/demo_offline.py')
-rw-r--r--searx/engines/demo_offline.py49
1 files changed, 38 insertions, 11 deletions
diff --git a/searx/engines/demo_offline.py b/searx/engines/demo_offline.py
index 13ec277f2..d9e5d0eb5 100644
--- a/searx/engines/demo_offline.py
+++ b/searx/engines/demo_offline.py
@@ -1,7 +1,12 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Within this module we implement a *demo offline engine*. Do not look to
-close to the implementation, its just a simple example. To get in use of this
-*demo* engine add the following entry to your engines list in ``settings.yml``:
+close to the implementation, its just a simple example.
+
+Configuration
+=============
+
+To get in use of this *demo* engine add the following entry to your engines list
+in ``settings.yml``:
.. code:: yaml
@@ -10,6 +15,9 @@ close to the implementation, its just a simple example. To get in use of this
shortcut: demo
disabled: false
+Implementations
+===============
+
"""
import typing as t
@@ -18,6 +26,10 @@ import json
from searx.result_types import EngineResults
from searx.enginelib import EngineCache
+if t.TYPE_CHECKING:
+ from searx.search.processors import RequestParams
+
+
engine_type = "offline"
categories = ["general"]
disabled = True
@@ -28,7 +40,7 @@ about = {
"official_api_documentation": None,
"use_official_api": False,
"require_api_key": False,
- "results": 'JSON',
+ "results": "JSON",
}
# if there is a need for globals, use a leading underline
@@ -39,10 +51,14 @@ CACHE: EngineCache
seconds."""
-def init(engine_settings: dict[str, t.Any]) -> None:
- """Initialization of the (offline) engine. The origin of this demo engine is a
- simple json string which is loaded in this example while the engine is
- initialized."""
+def setup(engine_settings: dict[str, t.Any]) -> bool:
+ """Dynamic setup of the engine settings.
+
+ The origin of this demo engine is a simple json string which is loaded in
+ this example while the engine is initialized.
+
+ For more details see :py:obj:`searx.enginelib.Engine.setup`.
+ """
global _my_offline_engine, CACHE # pylint: disable=global-statement
CACHE = EngineCache(engine_settings["name"])
@@ -55,12 +71,23 @@ def init(engine_settings: dict[str, t.Any]) -> None:
']' % engine_settings.get('name')
)
+ return True
+
-def search(query: str, params: dict[str, t.Any]) -> EngineResults:
+def init(engine_settings: dict[str, t.Any]) -> bool: # pylint: disable=unused-argument
+ """Initialization of the engine.
+
+ For more details see :py:obj:`searx.enginelib.Engine.init`.
+ """
+ return True
+
+
+def search(query: str, params: "RequestParams") -> EngineResults:
"""Query (offline) engine and return results. Assemble the list of results
- from your local engine. In this demo engine we ignore the 'query' term,
- usual you would pass the 'query' term to your local engine to filter out the
- results.
+ from your local engine.
+
+ In this demo engine we ignore the 'query' term, usual you would pass the
+ 'query' term to your local engine to filter out the results.
"""
res = EngineResults()