summaryrefslogtreecommitdiff
path: root/searx/enginelib
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-06-25 12:37:31 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-06-25 13:58:26 +0200
commite8706fb738da9feb21e596f403dddb40e69c8a7b (patch)
tree1ddf3dbd2860d65de879d9feecf7df01a7727680 /searx/enginelib
parent2e4a435134e0f677fbe24853dd81453a54770674 (diff)
downloadsearxng-e8706fb738da9feb21e596f403dddb40e69c8a7b.tar.gz
searxng-e8706fb738da9feb21e596f403dddb40e69c8a7b.zip
[fix] engine & network issues / documentation and type annotations
This patch fixes some quirks and issues related to the engines and the network. Each engine has its own network and this network was broken for the following engines[1]: - archlinux - bing - dailymotion - duckduckgo - google - peertube - startpage - wikipedia Since the files have been touched anyway, the type annotaions of the engine modules has also been completed so that error messages from the type checker are no longer reported. Related and (partial) fixed issue: - [1] https://github.com/searxng/searxng/issues/762#issuecomment-1605323861 - [2] https://github.com/searxng/searxng/issues/2513 - [3] https://github.com/searxng/searxng/issues/2515 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/enginelib')
-rw-r--r--searx/enginelib/__init__.py14
-rw-r--r--searx/enginelib/traits.py6
2 files changed, 16 insertions, 4 deletions
diff --git a/searx/enginelib/__init__.py b/searx/enginelib/__init__.py
index 00962e215..fd3019e6c 100644
--- a/searx/enginelib/__init__.py
+++ b/searx/enginelib/__init__.py
@@ -17,7 +17,7 @@
from __future__ import annotations
-from typing import Union, Dict, List, Callable, TYPE_CHECKING
+from typing import List, Callable, TYPE_CHECKING
if TYPE_CHECKING:
from searx.enginelib import traits
@@ -134,3 +134,15 @@ class Engine: # pylint: disable=too-few-public-methods
require_api_key: true
results: HTML
"""
+
+ using_tor_proxy: bool
+ """Using tor proxy (``true``) or not (``false``) for this engine."""
+
+ send_accept_language_header: bool
+ """When this option is activated, the language (locale) that is selected by
+ the user is used to build and send a ``Accept-Language`` header in the
+ request to the origin search engine."""
+
+ tokens: List[str]
+ """A list of secret tokens to make this engine *private*, more details see
+ :ref:`private engines`."""
diff --git a/searx/enginelib/traits.py b/searx/enginelib/traits.py
index ae27d46f1..8a7356ce2 100644
--- a/searx/enginelib/traits.py
+++ b/searx/enginelib/traits.py
@@ -13,6 +13,7 @@ used.
from __future__ import annotations
import json
import dataclasses
+import types
from typing import Dict, Iterable, Union, Callable, Optional, TYPE_CHECKING
from typing_extensions import Literal, Self
@@ -82,8 +83,7 @@ class EngineTraits:
"""
custom: Dict[str, Union[Dict[str, Dict], Iterable[str]]] = dataclasses.field(default_factory=dict)
- """A place to store engine's custom traits, not related to the SearXNG core
-
+ """A place to store engine's custom traits, not related to the SearXNG core.
"""
def get_language(self, searxng_locale: str, default=None):
@@ -228,7 +228,7 @@ class EngineTraitsMap(Dict[str, EngineTraits]):
return obj
- def set_traits(self, engine: Engine):
+ def set_traits(self, engine: Engine | types.ModuleType):
"""Set traits in a :py:obj:`Engine` namespace.
:param engine: engine instance build by :py:func:`searx.engines.load_engine`