summaryrefslogtreecommitdiff
path: root/searx/engines/startpage.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2024-05-29 07:32:16 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-05-29 07:52:18 +0200
commita20dfbbcbd35a945f0cbbf3532f835ebf9a36ae3 (patch)
treed9b6b52f4dac2ea7cb959d09c5e5e280aefb993d /searx/engines/startpage.py
parent8713aa6c4baeaa9d448c8fd469c1a2809a333ea3 (diff)
downloadsearxng-a20dfbbcbd35a945f0cbbf3532f835ebf9a36ae3.tar.gz
searxng-a20dfbbcbd35a945f0cbbf3532f835ebf9a36ae3.zip
[fix] engine startpage: fetch_traits() / if lang name unknown by babel
Workflow "Update data - update_engine_traits.py" fails last night [1]. This issue has already been reported by @allendema [2]. [1] https://github.com/searxng/searxng/actions/runs/9278028691/job/25528337485#step:6:168 [2] https://github.com/searxng/searxng/pull/3504/files#r1613559565 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/startpage.py')
-rw-r--r--searx/engines/startpage.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py
index d538a22e4..422ae7b20 100644
--- a/searx/engines/startpage.py
+++ b/searx/engines/startpage.py
@@ -78,6 +78,7 @@ Startpage's category (for Web-search, News, Videos, ..) is set by
yet implemented.
"""
+# pylint: disable=too-many-statements
from typing import TYPE_CHECKING
from collections import OrderedDict
@@ -88,7 +89,7 @@ from datetime import datetime, timedelta
import dateutil.parser
import lxml.html
-import babel
+import babel.localedata
from searx.utils import extract_text, eval_xpath, gen_useragent
from searx.network import get # see https://github.com/searxng/searxng/issues/762
@@ -439,10 +440,12 @@ def fetch_traits(engine_traits: EngineTraits):
# get the native name of every language known by babel
- for lang_code in filter(
- lambda lang_code: lang_code.find('_') == -1, babel.localedata.locale_identifiers() # type: ignore
- ):
- native_name = babel.Locale(lang_code).get_language_name().lower() # type: ignore
+ for lang_code in filter(lambda lang_code: lang_code.find('_') == -1, babel.localedata.locale_identifiers()):
+ native_name = babel.Locale(lang_code).get_language_name()
+ if not native_name:
+ print(f"ERROR: language name of startpage's language {lang_code} is unknown by babel")
+ continue
+ native_name = native_name.lower()
# add native name exactly as it is
catalog_engine2code[native_name] = lang_code