mirror of
https://github.com/searxng/searxng.git
synced 2026-06-16 06:46:52 +02:00
[fix] set language_support for engines with languages in traits (#6258)
In the past, the engine option ``language_support`` was not consistently maintained; with this patch, a ValueError is now thrown if an engine has languages in its traits but language_support is not set to True. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
committed by
Markus Heiser
parent
6c9dcd4242
commit
cf1410af8d
@@ -21,7 +21,7 @@ import msgspec
|
||||
|
||||
from searx import logger, settings
|
||||
from searx.utils import load_module
|
||||
|
||||
from searx.data import ENGINE_TRAITS
|
||||
from searx.enginelib import Engine, EngineAbout
|
||||
|
||||
logger = logger.getChild('engines')
|
||||
@@ -196,7 +196,7 @@ def update_engine_attributes(engine: "Engine | types.ModuleType", engine_data: d
|
||||
engine.about = EngineAbout(**kvargs)
|
||||
except TypeError as exc:
|
||||
raise TypeError(
|
||||
f"engine {engine_data['name']} ({engine_data['engine']}) - in the about section --> {exc}"
|
||||
f"engine '{engine_data['name']}' ({engine_data['engine']}) - in the about section --> {exc}"
|
||||
) from exc
|
||||
|
||||
for param_name, param_value in engine_data.items():
|
||||
@@ -214,6 +214,9 @@ def update_engine_attributes(engine: "Engine | types.ModuleType", engine_data: d
|
||||
if not hasattr(engine, arg_name):
|
||||
setattr(engine, arg_name, copy.deepcopy(arg_value))
|
||||
|
||||
if ENGINE_TRAITS.get(engine.name, {}).get("languages") and not engine.language_support:
|
||||
raise ValueError(f"engine '{engine.name}' ({engine_data['engine']}) language_support should be set to True")
|
||||
|
||||
|
||||
def update_attributes_for_tor(engine: "Engine | types.ModuleType"):
|
||||
if using_tor_proxy(engine) and hasattr(engine, 'onion_url'):
|
||||
|
||||
@@ -64,6 +64,7 @@ about: dict[str, t.Any] = {
|
||||
# engine dependent config
|
||||
categories = ["files", "books"]
|
||||
paging: bool = True
|
||||
language_support = True
|
||||
|
||||
# search-url
|
||||
base_url: list[str] | str = []
|
||||
|
||||
@@ -35,6 +35,7 @@ about = {
|
||||
categories = ["it", "software wikis"]
|
||||
paging = True
|
||||
main_wiki = "wiki.archlinux.org"
|
||||
language_support = True
|
||||
|
||||
|
||||
def request(query, params):
|
||||
|
||||
@@ -34,6 +34,7 @@ about = {
|
||||
categories = ["general", "social media"]
|
||||
paging = True
|
||||
time_range_support = True
|
||||
language_support = True
|
||||
|
||||
base_url = "https://boardreader.com"
|
||||
time_range_map = {"day": "1", "week": "7", "month": "30", "year": "365"}
|
||||
|
||||
@@ -40,6 +40,7 @@ categories = ["videos"]
|
||||
paging = True
|
||||
page_size = 10
|
||||
|
||||
language_support = True
|
||||
time_range_support = True
|
||||
time_delta_dict = {
|
||||
"day": timedelta(days=1),
|
||||
|
||||
@@ -203,6 +203,7 @@ about: dict[str, str | bool] = {
|
||||
categories: list[str] = ["general", "web"]
|
||||
paging: bool = True
|
||||
time_range_support: bool = True
|
||||
language_support = True
|
||||
safesearch: bool = True
|
||||
"""DDG-lite: user can't select but the results are filtered."""
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON (site requires js to get images)",
|
||||
}
|
||||
language_support = True
|
||||
|
||||
# engine dependent config
|
||||
categories = []
|
||||
|
||||
@@ -26,6 +26,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON",
|
||||
}
|
||||
language_support = True
|
||||
|
||||
# engine dependent config
|
||||
categories = ["weather"]
|
||||
|
||||
@@ -57,6 +57,7 @@ max_page = 50
|
||||
.. _Google max 50 pages: https://github.com/searxng/searxng/issues/2982
|
||||
"""
|
||||
time_range_support = True
|
||||
language_support = True
|
||||
safesearch = True
|
||||
|
||||
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
||||
|
||||
@@ -43,6 +43,7 @@ max_page = 50
|
||||
"""
|
||||
|
||||
time_range_support = True
|
||||
language_support = True
|
||||
safesearch = True
|
||||
|
||||
filter_mapping = {0: 'images', 1: 'active', 2: 'active'}
|
||||
|
||||
@@ -66,6 +66,7 @@ about = {
|
||||
categories = ["news"]
|
||||
paging = False
|
||||
time_range_support = False
|
||||
language_support = True
|
||||
|
||||
# Google-News results are always *SafeSearch*. Option 'safesearch' is set to
|
||||
# False here.
|
||||
|
||||
@@ -20,6 +20,7 @@ about = {
|
||||
}
|
||||
paging = True # paging is only supported for general search
|
||||
safesearch = True
|
||||
language_support = True
|
||||
time_range_support = True # time range search is supported for general and news
|
||||
max_page = 10
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ about = {
|
||||
# Engine configuration
|
||||
paging = True
|
||||
time_range_support = True
|
||||
language_support = True
|
||||
results_per_page = 20
|
||||
categories = ["videos"]
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON",
|
||||
}
|
||||
language_support = True
|
||||
|
||||
# engine dependent config
|
||||
categories = ["videos"]
|
||||
|
||||
@@ -26,6 +26,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON",
|
||||
}
|
||||
language_support = True
|
||||
paging = True
|
||||
categories = ["music", "radio"]
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": 'JSON',
|
||||
}
|
||||
language_support = True
|
||||
|
||||
# engine dependent config
|
||||
categories = ['videos']
|
||||
|
||||
@@ -131,6 +131,7 @@ max_page = 18
|
||||
"""Tested 18 pages maximum (argument ``page``), to be save max is set to 20."""
|
||||
|
||||
time_range_support = True
|
||||
language_support = True
|
||||
safesearch = True
|
||||
|
||||
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
||||
|
||||
@@ -40,6 +40,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": 'JSON',
|
||||
}
|
||||
language_support = True
|
||||
|
||||
display_type = ["infobox"]
|
||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||
|
||||
@@ -72,6 +72,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON",
|
||||
}
|
||||
language_support = True
|
||||
|
||||
display_type = ["infobox"]
|
||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||
|
||||
@@ -22,6 +22,7 @@ about = {
|
||||
"require_api_key": False,
|
||||
"results": "JSON",
|
||||
}
|
||||
language_support = True
|
||||
|
||||
base_url = "https://api.yep.com"
|
||||
web_base_url = "https://yep.com"
|
||||
|
||||
@@ -61,6 +61,7 @@ about: dict[str, t.Any] = {
|
||||
|
||||
categories: list[str] = ["files", "books"]
|
||||
paging: bool = True
|
||||
language_support = True
|
||||
base_url: str = "https://zlibrary-global.se"
|
||||
|
||||
zlib_year_from: str = ""
|
||||
|
||||
Reference in New Issue
Block a user