summaryrefslogtreecommitdiff
path: root/searx/engines/startpage.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2022-01-05 13:08:56 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2022-01-10 11:22:38 +0100
commit1cbcddb3f703b0ee076ac5ce0b514246a21472ec (patch)
tree2124c3336389c3ab76237dff6fcf2bb4728844e9 /searx/engines/startpage.py
parentf1f5e69c425389a5cb7e7a437b3a39c0d7513022 (diff)
downloadsearxng-1cbcddb3f703b0ee076ac5ce0b514246a21472ec.tar.gz
searxng-1cbcddb3f703b0ee076ac5ce0b514246a21472ec.zip
[pylint] Startpage engine
Fix remarks from pylint Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/startpage.py')
-rw-r--r--searx/engines/startpage.py38
1 files changed, 25 insertions, 13 deletions
diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py
index 1fd259dad..eaa157705 100644
--- a/searx/engines/startpage.py
+++ b/searx/engines/startpage.py
@@ -1,17 +1,20 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
+# lint: pylint
+"""Startpage (Web)
+
"""
- Startpage (Web)
-"""
+
+import re
from urllib.parse import urlencode
+from unicodedata import normalize, combining
+from datetime import datetime, timedelta
-from lxml import html
from dateutil import parser
-from datetime import datetime, timedelta
-import re
-from unicodedata import normalize, combining
+from lxml import html
from babel import Locale
from babel.localedata import locale_identifiers
+
from searx.utils import extract_text, eval_xpath, match_language
# about
@@ -135,10 +138,11 @@ def response(resp):
# get supported languages from their site
def _fetch_supported_languages(resp):
- # startpage's language selector is a mess
- # each option has a displayed name and a value, either of which may represent the language name
- # in the native script, the language name in English, an English transliteration of the native name,
- # the English name of the writing script used by the language, or occasionally something else entirely.
+ # startpage's language selector is a mess each option has a displayed name
+ # and a value, either of which may represent the language name in the native
+ # script, the language name in English, an English transliteration of the
+ # native name, the English name of the writing script used by the language,
+ # or occasionally something else entirely.
# this cases are so special they need to be hardcoded, a couple of them are mispellings
language_names = {
@@ -152,7 +156,15 @@ def _fetch_supported_languages(resp):
}
# get the English name of every language known by babel
- language_names.update({name.lower(): lang_code for lang_code, name in Locale('en')._data['languages'].items()})
+ language_names.update(
+ {
+ # fmt: off
+ name.lower(): lang_code
+ # pylint: disable=protected-access
+ for lang_code, name in Locale('en')._data['languages'].items()
+ # fmt: on
+ }
+ )
# get the native name of every language known by babel
for lang_code in filter(lambda lang_code: lang_code.find('_') == -1, locale_identifiers()):
@@ -177,8 +189,8 @@ def _fetch_supported_languages(resp):
if isinstance(lang_code, str):
supported_languages[lang_code] = {'alias': sp_option_value}
elif isinstance(lang_code, list):
- for lc in lang_code:
- supported_languages[lc] = {'alias': sp_option_value}
+ for _lc in lang_code:
+ supported_languages[_lc] = {'alias': sp_option_value}
else:
print('Unknown language option in Startpage: {} ({})'.format(sp_option_value, sp_option_text))