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 import logger, settings
|
||||||
from searx.utils import load_module
|
from searx.utils import load_module
|
||||||
|
from searx.data import ENGINE_TRAITS
|
||||||
from searx.enginelib import Engine, EngineAbout
|
from searx.enginelib import Engine, EngineAbout
|
||||||
|
|
||||||
logger = logger.getChild('engines')
|
logger = logger.getChild('engines')
|
||||||
@@ -196,7 +196,7 @@ def update_engine_attributes(engine: "Engine | types.ModuleType", engine_data: d
|
|||||||
engine.about = EngineAbout(**kvargs)
|
engine.about = EngineAbout(**kvargs)
|
||||||
except TypeError as exc:
|
except TypeError as exc:
|
||||||
raise TypeError(
|
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
|
) from exc
|
||||||
|
|
||||||
for param_name, param_value in engine_data.items():
|
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):
|
if not hasattr(engine, arg_name):
|
||||||
setattr(engine, arg_name, copy.deepcopy(arg_value))
|
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"):
|
def update_attributes_for_tor(engine: "Engine | types.ModuleType"):
|
||||||
if using_tor_proxy(engine) and hasattr(engine, 'onion_url'):
|
if using_tor_proxy(engine) and hasattr(engine, 'onion_url'):
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ about: dict[str, t.Any] = {
|
|||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ["files", "books"]
|
categories = ["files", "books"]
|
||||||
paging: bool = True
|
paging: bool = True
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# search-url
|
# search-url
|
||||||
base_url: list[str] | str = []
|
base_url: list[str] | str = []
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ about = {
|
|||||||
categories = ["it", "software wikis"]
|
categories = ["it", "software wikis"]
|
||||||
paging = True
|
paging = True
|
||||||
main_wiki = "wiki.archlinux.org"
|
main_wiki = "wiki.archlinux.org"
|
||||||
|
language_support = True
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
def request(query, params):
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ about = {
|
|||||||
categories = ["general", "social media"]
|
categories = ["general", "social media"]
|
||||||
paging = True
|
paging = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
language_support = True
|
||||||
|
|
||||||
base_url = "https://boardreader.com"
|
base_url = "https://boardreader.com"
|
||||||
time_range_map = {"day": "1", "week": "7", "month": "30", "year": "365"}
|
time_range_map = {"day": "1", "week": "7", "month": "30", "year": "365"}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ categories = ["videos"]
|
|||||||
paging = True
|
paging = True
|
||||||
page_size = 10
|
page_size = 10
|
||||||
|
|
||||||
|
language_support = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
time_delta_dict = {
|
time_delta_dict = {
|
||||||
"day": timedelta(days=1),
|
"day": timedelta(days=1),
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ about: dict[str, str | bool] = {
|
|||||||
categories: list[str] = ["general", "web"]
|
categories: list[str] = ["general", "web"]
|
||||||
paging: bool = True
|
paging: bool = True
|
||||||
time_range_support: bool = True
|
time_range_support: bool = True
|
||||||
|
language_support = True
|
||||||
safesearch: bool = True
|
safesearch: bool = True
|
||||||
"""DDG-lite: user can't select but the results are filtered."""
|
"""DDG-lite: user can't select but the results are filtered."""
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON (site requires js to get images)",
|
"results": "JSON (site requires js to get images)",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = []
|
categories = []
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON",
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ["weather"]
|
categories = ["weather"]
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ max_page = 50
|
|||||||
.. _Google max 50 pages: https://github.com/searxng/searxng/issues/2982
|
.. _Google max 50 pages: https://github.com/searxng/searxng/issues/2982
|
||||||
"""
|
"""
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
language_support = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
|
||||||
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ max_page = 50
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
language_support = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
|
||||||
filter_mapping = {0: 'images', 1: 'active', 2: 'active'}
|
filter_mapping = {0: 'images', 1: 'active', 2: 'active'}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ about = {
|
|||||||
categories = ["news"]
|
categories = ["news"]
|
||||||
paging = False
|
paging = False
|
||||||
time_range_support = False
|
time_range_support = False
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# Google-News results are always *SafeSearch*. Option 'safesearch' is set to
|
# Google-News results are always *SafeSearch*. Option 'safesearch' is set to
|
||||||
# False here.
|
# False here.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ about = {
|
|||||||
}
|
}
|
||||||
paging = True # paging is only supported for general search
|
paging = True # paging is only supported for general search
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
language_support = True
|
||||||
time_range_support = True # time range search is supported for general and news
|
time_range_support = True # time range search is supported for general and news
|
||||||
max_page = 10
|
max_page = 10
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ about = {
|
|||||||
# Engine configuration
|
# Engine configuration
|
||||||
paging = True
|
paging = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
language_support = True
|
||||||
results_per_page = 20
|
results_per_page = 20
|
||||||
categories = ["videos"]
|
categories = ["videos"]
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON",
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ["videos"]
|
categories = ["videos"]
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON",
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
paging = True
|
paging = True
|
||||||
categories = ["music", "radio"]
|
categories = ["music", "radio"]
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": 'JSON',
|
"results": 'JSON',
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
# engine dependent config
|
# engine dependent config
|
||||||
categories = ['videos']
|
categories = ['videos']
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ max_page = 18
|
|||||||
"""Tested 18 pages maximum (argument ``page``), to be save max is set to 20."""
|
"""Tested 18 pages maximum (argument ``page``), to be save max is set to 20."""
|
||||||
|
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
|
language_support = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
|
|
||||||
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
time_range_dict = {"day": "d", "week": "w", "month": "m", "year": "y"}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": 'JSON',
|
"results": 'JSON',
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
display_type = ["infobox"]
|
display_type = ["infobox"]
|
||||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON",
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
display_type = ["infobox"]
|
display_type = ["infobox"]
|
||||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ about = {
|
|||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": "JSON",
|
"results": "JSON",
|
||||||
}
|
}
|
||||||
|
language_support = True
|
||||||
|
|
||||||
base_url = "https://api.yep.com"
|
base_url = "https://api.yep.com"
|
||||||
web_base_url = "https://yep.com"
|
web_base_url = "https://yep.com"
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ about: dict[str, t.Any] = {
|
|||||||
|
|
||||||
categories: list[str] = ["files", "books"]
|
categories: list[str] = ["files", "books"]
|
||||||
paging: bool = True
|
paging: bool = True
|
||||||
|
language_support = True
|
||||||
base_url: str = "https://zlibrary-global.se"
|
base_url: str = "https://zlibrary-global.se"
|
||||||
|
|
||||||
zlib_year_from: str = ""
|
zlib_year_from: str = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user