@@ -1,17 +1,20 @@
11# SPDX-License-Identifier: AGPL-3.0-or-later
2+# lint: pylint
3+"""Startpage (Web)
4+
25"""
3− Startpage (Web)
4−"""
6+
7+import re
58
69from urllib.parse import urlencode
10+from unicodedata import normalize, combining
11+from datetime import datetime, timedelta
712
8−from lxml import html
913from dateutil import parser
10−from datetime import datetime, timedelta
11−import re
12−from unicodedata import normalize, combining
14+from lxml import html
1315from babel import Locale
1416from babel.localedata import locale_identifiers
17+
1518from searx.utils import extract_text, eval_xpath, match_language
1619
1720# about
@@ -140,10 +143,11 @@ def response(resp):
140143
141144# get supported languages from their site
142145def _fetch_supported_languages(resp):
143− # startpage's language selector is a mess
144− # each option has a displayed name and a value, either of which may represent the language name
145− # in the native script, the language name in English, an English transliteration of the native name,
146− # the English name of the writing script used by the language, or occasionally something else entirely.
146+ # startpage's language selector is a mess each option has a displayed name
147+ # and a value, either of which may represent the language name in the native
148+ # script, the language name in English, an English transliteration of the
149+ # native name, the English name of the writing script used by the language,
150+ # or occasionally something else entirely.
147151
148152 # this cases are so special they need to be hardcoded, a couple of them are mispellings
149153 language_names = {
@@ -157,7 +161,15 @@ def _fetch_supported_languages(resp):
157161 }
158162
159163 # get the English name of every language known by babel
160− language_names.update({name.lower(): lang_code for lang_code, name in Locale('en')._data['languages'].items()})
164+ language_names.update(
165+ {
166+ # fmt: off
167+ name.lower(): lang_code
168+ # pylint: disable=protected-access
169+ for lang_code, name in Locale('en')._data['languages'].items()
170+ # fmt: on
171+ }
172+ )
161173
162174 # get the native name of every language known by babel
163175 for lang_code in filter(lambda lang_code: lang_code.find('_') == -1, locale_identifiers()):
@@ -182,8 +194,8 @@ def _fetch_supported_languages(resp):
182194 if isinstance(lang_code, str):
183195 supported_languages[lang_code] = {'alias': sp_option_value}
184196 elif isinstance(lang_code, list):
185− for lc in lang_code:
186− supported_languages[lc] = {'alias': sp_option_value}
197+ for _lc in lang_code:
198+ supported_languages[_lc] = {'alias': sp_option_value}
187199 else:
188200 print('Unknown language option in Startpage: {} ({})'.format(sp_option_value, sp_option_text))
189201