From 8205f170ff983e5240d32dc17d7fdb526ebe5fe7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 11 Mar 2024 07:45:08 +0100 Subject: [PATCH] [mod] pylint all engines without PYLINT_SEARXNG_DISABLE_OPTION Signed-off-by: Markus Heiser --- manage | 14 +++----- searx/engines/1337x.py | 5 +-- searx/engines/9gag.py | 1 - searx/engines/__init__.py | 1 - searx/engines/ahmia.py | 2 +- searx/engines/annas_archive.py | 1 - searx/engines/apkmirror.py | 1 - searx/engines/apple_app_store.py | 5 ++- searx/engines/apple_maps.py | 1 - searx/engines/archlinux.py | 1 - searx/engines/artic.py | 1 - searx/engines/arxiv.py | 9 ++--- searx/engines/ask.py | 1 - searx/engines/bandcamp.py | 1 - searx/engines/base.py | 20 ++++++----- searx/engines/bilibili.py | 1 - searx/engines/bing.py | 1 - searx/engines/bing_images.py | 1 - searx/engines/bing_news.py | 1 - searx/engines/bing_videos.py | 3 +- searx/engines/bpb.py | 1 - searx/engines/brave.py | 1 - searx/engines/bt4g.py | 1 - searx/engines/btdigg.py | 5 +-- searx/engines/chefkoch.py | 1 - searx/engines/command.py | 7 ++-- searx/engines/core.py | 1 - searx/engines/cppreference.py | 1 - searx/engines/crossref.py | 1 - searx/engines/currency_convert.py | 1 - searx/engines/dailymotion.py | 1 - searx/engines/deepl.py | 1 - searx/engines/deezer.py | 2 +- searx/engines/demo_offline.py | 1 - searx/engines/demo_online.py | 1 - searx/engines/destatis.py | 1 - searx/engines/deviantart.py | 1 - searx/engines/dictzone.py | 4 +-- searx/engines/digbt.py | 4 +-- searx/engines/docker_hub.py | 1 - searx/engines/doku.py | 10 +++--- searx/engines/duckduckgo.py | 1 - searx/engines/duckduckgo_definitions.py | 1 - searx/engines/duckduckgo_weather.py | 1 - searx/engines/dummy-offline.py | 7 ++-- searx/engines/dummy.py | 8 ++--- searx/engines/ebay.py | 3 +- searx/engines/emojipedia.py | 1 - searx/engines/flickr.py | 4 +-- searx/engines/flickr_noapi.py | 1 - searx/engines/fyyd.py | 1 - searx/engines/genius.py | 1 - searx/engines/gentoo.py | 4 +-- searx/engines/github.py | 3 +- searx/engines/goodreads.py | 1 - searx/engines/google.py | 1 - searx/engines/google_images.py | 1 - searx/engines/google_news.py | 1 - searx/engines/google_play.py | 1 - searx/engines/google_scholar.py | 1 - searx/engines/google_videos.py | 1 - searx/engines/hackernews.py | 1 - searx/engines/imdb.py | 2 -- searx/engines/imgur.py | 1 - searx/engines/internet_archive_scholar.py | 1 - searx/engines/invidious.py | 1 - searx/engines/json_engine.py | 42 ++++++++++++++--------- searx/engines/kickass.py | 1 - searx/engines/lemmy.py | 1 - searx/engines/lib_rs.py | 1 - searx/engines/lingva.py | 1 - searx/engines/livespace.py | 1 - searx/engines/mastodon.py | 1 - searx/engines/material_icons.py | 2 +- searx/engines/mediathekviewweb.py | 1 - searx/engines/mediawiki.py | 1 - searx/engines/meilisearch.py | 1 - searx/engines/metacpan.py | 1 - searx/engines/mixcloud.py | 1 - searx/engines/mongodb.py | 1 - searx/engines/moviepilot.py | 1 - searx/engines/mozhi.py | 1 - searx/engines/mrs.py | 1 - searx/engines/mullvad_leta.py | 1 - searx/engines/mwmbl.py | 1 - searx/engines/mysql_server.py | 1 - searx/engines/npm.py | 1 - searx/engines/nyaa.py | 1 - searx/engines/odysee.py | 1 - searx/engines/opensemantic.py | 6 ++-- searx/engines/openstreetmap.py | 1 - searx/engines/pdbe.py | 2 +- searx/engines/peertube.py | 1 - searx/engines/photon.py | 2 +- searx/engines/pinterest.py | 1 - searx/engines/piped.py | 1 - searx/engines/piratebay.py | 4 +-- searx/engines/pixiv.py | 1 - searx/engines/pkg_go_dev.py | 1 - searx/engines/podcastindex.py | 1 - searx/engines/postgresql.py | 1 - searx/engines/presearch.py | 1 - searx/engines/pubmed.py | 19 ++++++---- searx/engines/pypi.py | 1 - searx/engines/qwant.py | 1 - searx/engines/radio_browser.py | 1 - searx/engines/recoll.py | 1 - searx/engines/reddit.py | 2 +- searx/engines/redis_server.py | 1 - searx/engines/rottentomatoes.py | 1 - searx/engines/rumble.py | 8 +++-- searx/engines/searchcode_code.py | 1 - searx/engines/searx_engine.py | 2 +- searx/engines/seekr.py | 1 - searx/engines/semantic_scholar.py | 1 - searx/engines/sepiasearch.py | 1 - searx/engines/seznam.py | 1 - searx/engines/sjp.py | 1 - searx/engines/solidtorrents.py | 2 +- searx/engines/solr.py | 1 - searx/engines/soundcloud.py | 19 +++++----- searx/engines/spotify.py | 8 ++--- searx/engines/springer.py | 1 - searx/engines/sqlite.py | 1 - searx/engines/stackexchange.py | 1 - searx/engines/startpage.py | 1 - searx/engines/stract.py | 7 ++-- searx/engines/svgrepo.py | 1 - searx/engines/tagesschau.py | 1 - searx/engines/tineye.py | 1 - searx/engines/tokyotoshokan.py | 13 +++---- searx/engines/tootfinder.py | 1 - searx/engines/torznab.py | 1 - searx/engines/translated.py | 6 ++-- searx/engines/unsplash.py | 1 - searx/engines/voidlinux.py | 1 - searx/engines/wallhaven.py | 1 - searx/engines/wikicommons.py | 1 - searx/engines/wikidata.py | 1 - searx/engines/wikipedia.py | 1 - searx/engines/wolframalpha_api.py | 9 ++--- searx/engines/wolframalpha_noapi.py | 6 ++-- searx/engines/wttr.py | 1 - searx/engines/www1x.py | 1 - searx/engines/xpath.py | 1 - searx/engines/yacy.py | 1 - searx/engines/yahoo.py | 1 - searx/engines/yahoo_news.py | 1 - searx/engines/yandex_music.py | 1 - searx/engines/yep.py | 1 - searx/engines/youtube_api.py | 3 +- searx/engines/youtube_noapi.py | 9 +++-- searx/engines/yummly.py | 1 - searx/engines/zlibrary.py | 1 - utils/lib_sxng_test.sh | 18 ++++++---- 155 files changed, 166 insertions(+), 258 deletions(-) mode change 100644 => 100755 utils/lib_sxng_test.sh diff --git a/manage b/manage index efb6c265a..9871906d2 100755 --- a/manage +++ b/manage @@ -64,6 +64,11 @@ pylint.FILES() { find . -name searxng.msg } +PYLINT_FILES=() +while IFS= read -r line; do + PYLINT_FILES+=("$line") +done <<< "$(pylint.FILES)" + YAMLLINT_FILES=() while IFS= read -r line; do YAMLLINT_FILES+=("$line") @@ -77,9 +82,6 @@ PYLINT_SEARXNG_DISABLE_OPTION="\ I,C,R,\ W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401,\ E1136" -PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES="traits,supported_languages,language_aliases,logger,categories" -PYLINT_OPTIONS="-m pylint -j 0 --rcfile .pylintrc" - help() { nvm.help cat <` is limited (see remarks). diff --git a/searx/engines/bt4g.py b/searx/engines/bt4g.py index 786aa1920..98a8c3087 100644 --- a/searx/engines/bt4g.py +++ b/searx/engines/bt4g.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """BT4G_ (bt4g.com) is not a tracker and doesn't store any content and only collects torrent metadata (such as file names and file sizes) and a magnet link (torrent identifier). diff --git a/searx/engines/btdigg.py b/searx/engines/btdigg.py index c5dd92105..588d62093 100644 --- a/searx/engines/btdigg.py +++ b/searx/engines/btdigg.py @@ -3,8 +3,9 @@ BTDigg (Videos, Music, Files) """ -from lxml import html from urllib.parse import quote, urljoin + +from lxml import html from searx.utils import extract_text, get_torrent_size # about @@ -67,7 +68,7 @@ def response(resp): # convert files to int if possible try: files = int(files) - except: + except: # pylint: disable=bare-except files = None magnetlink = result.xpath('.//div[@class="torrent_magnet"]//a')[0].attrib['href'] diff --git a/searx/engines/chefkoch.py b/searx/engines/chefkoch.py index 9dc6ae0dd..cffa59a0f 100644 --- a/searx/engines/chefkoch.py +++ b/searx/engines/chefkoch.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Chefkoch is a German database of recipes. """ diff --git a/searx/engines/command.py b/searx/engines/command.py index ffb87509a..176388e3a 100644 --- a/searx/engines/command.py +++ b/searx/engines/command.py @@ -106,7 +106,7 @@ def init(engine_settings): if 'command' not in engine_settings: raise ValueError('engine command : missing configuration key: command') - global command, working_dir, delimiter, parse_regex, environment_variables + global command, working_dir, delimiter, parse_regex, environment_variables # pylint: disable=global-statement command = engine_settings['command'] @@ -172,7 +172,7 @@ def _get_results_from_process(results, cmd, pageno): _command_logger.debug('skipped result:', raw_result) continue - if start <= count and count <= end: + if start <= count and count <= end: # pylint: disable=chained-comparison result['template'] = result_template results.append(result) @@ -185,6 +185,7 @@ def _get_results_from_process(results, cmd, pageno): return_code = process.wait(timeout=timeout) if return_code != 0: raise RuntimeError('non-zero return code when running command', cmd, return_code) + return None def __get_results_limits(pageno): @@ -230,7 +231,7 @@ def __parse_single_result(raw_result): elements = raw_result.split(delimiter['chars'], maxsplit=len(delimiter['keys']) - 1) if len(elements) != len(delimiter['keys']): return {} - for i in range(len(elements)): + for i in range(len(elements)): # pylint: disable=consider-using-enumerate result[delimiter['keys'][i]] = elements[i] if parse_regex: diff --git a/searx/engines/core.py b/searx/engines/core.py index 2fa66e226..5305cb224 100644 --- a/searx/engines/core.py +++ b/searx/engines/core.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """CORE (science) """ diff --git a/searx/engines/cppreference.py b/searx/engines/cppreference.py index b13cf730b..5ffbf6e59 100644 --- a/searx/engines/cppreference.py +++ b/searx/engines/cppreference.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Cppreference """ from lxml import html diff --git a/searx/engines/crossref.py b/searx/engines/crossref.py index c2ed7763f..d8dfc568d 100644 --- a/searx/engines/crossref.py +++ b/searx/engines/crossref.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """CrossRef""" from urllib.parse import urlencode diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 2e87ef751..cbb1d6cc4 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Currency convert (DuckDuckGo) """ diff --git a/searx/engines/dailymotion.py b/searx/engines/dailymotion.py index 99da9616c..4dfca9ef3 100644 --- a/searx/engines/dailymotion.py +++ b/searx/engines/dailymotion.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """ Dailymotion (Videos) ~~~~~~~~~~~~~~~~~~~~ diff --git a/searx/engines/deepl.py b/searx/engines/deepl.py index 85072710f..9e4fbe21e 100644 --- a/searx/engines/deepl.py +++ b/searx/engines/deepl.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Deepl translation engine""" from json import loads diff --git a/searx/engines/deezer.py b/searx/engines/deezer.py index 3dd787c48..f4a4783ea 100644 --- a/searx/engines/deezer.py +++ b/searx/engines/deezer.py @@ -45,7 +45,7 @@ def response(resp): for result in search_res.get('data', []): if result['type'] == 'track': title = result['title'] - url = result['link'] + url = result['link'] # pylint: disable=redefined-outer-name if url.startswith('http://'): url = 'https' + url[4:] diff --git a/searx/engines/demo_offline.py b/searx/engines/demo_offline.py index 9d6e3b52d..97659465a 100644 --- a/searx/engines/demo_offline.py +++ b/searx/engines/demo_offline.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Within this module we implement a *demo offline engine*. Do not look to close to the implementation, its just a simple example. To get in use of this *demo* engine add the following entry to your engines list in ``settings.yml``: diff --git a/searx/engines/demo_online.py b/searx/engines/demo_online.py index 33cfde822..6accc0033 100644 --- a/searx/engines/demo_online.py +++ b/searx/engines/demo_online.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Within this module we implement a *demo online engine*. Do not look to close to the implementation, its just a simple example which queries `The Art Institute of Chicago `_ diff --git a/searx/engines/destatis.py b/searx/engines/destatis.py index 2d19b340f..9e5355c6f 100644 --- a/searx/engines/destatis.py +++ b/searx/engines/destatis.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """DeStatis """ diff --git a/searx/engines/deviantart.py b/searx/engines/deviantart.py index fa88d9389..b19813a35 100644 --- a/searx/engines/deviantart.py +++ b/searx/engines/deviantart.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Deviantart (Images) """ diff --git a/searx/engines/dictzone.py b/searx/engines/dictzone.py index 126e75374..a6e1ae289 100644 --- a/searx/engines/dictzone.py +++ b/searx/engines/dictzone.py @@ -26,7 +26,7 @@ results_xpath = './/table[@id="r"]/tr' https_support = True -def request(query, params): +def request(query, params): # pylint: disable=unused-argument params['url'] = url.format(from_lang=params['from_lang'][2], to_lang=params['to_lang'][2], query=params['query']) return params @@ -40,7 +40,7 @@ def response(resp): for k, result in enumerate(eval_xpath(dom, results_xpath)[1:]): try: from_result, to_results_raw = eval_xpath(result, './td') - except: + except: # pylint: disable=bare-except continue to_results = [] diff --git a/searx/engines/digbt.py b/searx/engines/digbt.py index 2914e9228..ae78f1a9e 100644 --- a/searx/engines/digbt.py +++ b/searx/engines/digbt.py @@ -37,9 +37,9 @@ def response(resp): search_res = dom.xpath('.//td[@class="x-item"]') if not search_res: - return list() + return [] - results = list() + results = [] for result in search_res: url = urljoin(URL, result.xpath('.//a[@title]/@href')[0]) title = extract_text(result.xpath('.//a[@title]')) diff --git a/searx/engines/docker_hub.py b/searx/engines/docker_hub.py index 1e2527823..48b4dcf0e 100644 --- a/searx/engines/docker_hub.py +++ b/searx/engines/docker_hub.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Docker Hub (IT) """ diff --git a/searx/engines/doku.py b/searx/engines/doku.py index 08f56bbe7..dfe643c9e 100644 --- a/searx/engines/doku.py +++ b/searx/engines/doku.py @@ -18,7 +18,7 @@ about = { } # engine dependent config -categories = ['general'] # TODO , 'images', 'music', 'videos', 'files' +categories = ['general'] # 'images', 'music', 'videos', 'files' paging = False number_of_results = 5 @@ -31,8 +31,8 @@ search_url = ( '&{query}' # fmt: on ) -# TODO '&startRecord={offset}' -# TODO '&maximumRecords={limit}' +# '&startRecord={offset}' +# '&maximumRecords={limit}' # do search-request @@ -54,7 +54,7 @@ def response(resp): for r in eval_xpath(doc, '//div[@class="search_quickresult"]/ul/li'): try: res_url = eval_xpath(r, './/a[@class="wikilink1"]/@href')[-1] - except: + except: # pylint: disable=bare-except continue if not res_url: @@ -76,7 +76,7 @@ def response(resp): # append result results.append({'title': title, 'content': content, 'url': base_url + res_url}) - except: + except: # pylint: disable=bare-except continue if not res_url: diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index 636dfccd5..ac78c3b60 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """ DuckDuckGo Lite ~~~~~~~~~~~~~~~ diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py index 49f9dee34..e8146cc3e 100644 --- a/searx/engines/duckduckgo_definitions.py +++ b/searx/engines/duckduckgo_definitions.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """ DuckDuckGo Instant Answer API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/searx/engines/duckduckgo_weather.py b/searx/engines/duckduckgo_weather.py index 3d59c4b0a..715b0dfd1 100644 --- a/searx/engines/duckduckgo_weather.py +++ b/searx/engines/duckduckgo_weather.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """ DuckDuckGo Weather ~~~~~~~~~~~~~~~~~~ diff --git a/searx/engines/dummy-offline.py b/searx/engines/dummy-offline.py index 632eeb2b3..545c947ff 100644 --- a/searx/engines/dummy-offline.py +++ b/searx/engines/dummy-offline.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Dummy Offline +# pylint: disable=invalid-name +"""Dummy Offline + """ @@ -14,7 +15,7 @@ about = { } -def search(query, request_params): +def search(query, request_params): # pylint: disable=unused-argument return [ { 'result': 'this is what you get', diff --git a/searx/engines/dummy.py b/searx/engines/dummy.py index 1a1b57d8c..2d4301b42 100644 --- a/searx/engines/dummy.py +++ b/searx/engines/dummy.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Dummy +"""Dummy + """ # about @@ -15,10 +15,10 @@ about = { # do search-request -def request(query, params): +def request(query, params): # pylint: disable=unused-argument return params # get response from search-request -def response(resp): +def response(resp): # pylint: disable=unused-argument return [] diff --git a/searx/engines/ebay.py b/searx/engines/ebay.py index 07870f044..f1d09d878 100644 --- a/searx/engines/ebay.py +++ b/searx/engines/ebay.py @@ -3,9 +3,10 @@ Ebay (Videos, Music, Files) """ +from urllib.parse import quote + from lxml import html from searx.engines.xpath import extract_text -from urllib.parse import quote # about about = { diff --git a/searx/engines/emojipedia.py b/searx/engines/emojipedia.py index a1f3ef7b8..9bda21234 100644 --- a/searx/engines/emojipedia.py +++ b/searx/engines/emojipedia.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Emojipedia Emojipedia is an emoji reference website which documents the meaning and diff --git a/searx/engines/flickr.py b/searx/engines/flickr.py index b7cd76808..89c3b8cfd 100644 --- a/searx/engines/flickr.py +++ b/searx/engines/flickr.py @@ -78,12 +78,10 @@ def response(resp): else: thumbnail_src = img_src - url = build_flickr_url(photo['owner'], photo['id']) - # append result results.append( { - 'url': url, + 'url': build_flickr_url(photo['owner'], photo['id']), 'title': photo['title'], 'img_src': img_src, 'thumbnail_src': thumbnail_src, diff --git a/searx/engines/flickr_noapi.py b/searx/engines/flickr_noapi.py index ebd61570f..6d5fd84d1 100644 --- a/searx/engines/flickr_noapi.py +++ b/searx/engines/flickr_noapi.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Flickr (Images) """ diff --git a/searx/engines/fyyd.py b/searx/engines/fyyd.py index 10ba91f7f..3810e5e81 100644 --- a/searx/engines/fyyd.py +++ b/searx/engines/fyyd.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Fyyd (podcasts) """ diff --git a/searx/engines/genius.py b/searx/engines/genius.py index db1f66603..b25b01568 100644 --- a/searx/engines/genius.py +++ b/searx/engines/genius.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint # pylint: disable=invalid-name """Genius diff --git a/searx/engines/gentoo.py b/searx/engines/gentoo.py index cf193c2a3..4a4e085ba 100644 --- a/searx/engines/gentoo.py +++ b/searx/engines/gentoo.py @@ -107,7 +107,7 @@ def request(query, params): def response(resp): # get the base URL for the language in which request was made language = locale_to_lang_code(resp.search_params['language']) - base_url = get_lang_urls(language)['base'] + url = get_lang_urls(language)['base'] results = [] @@ -116,7 +116,7 @@ def response(resp): # parse results for result in dom.xpath(xpath_results): link = result.xpath(xpath_link)[0] - href = urljoin(base_url, link.attrib.get('href')) + href = urljoin(url, link.attrib.get('href')) title = extract_text(link) content = extract_text(result.xpath(xpath_content)) diff --git a/searx/engines/github.py b/searx/engines/github.py index 36eca4c53..a20f14d14 100644 --- a/searx/engines/github.py +++ b/searx/engines/github.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint - """Github (IT) + """ from urllib.parse import urlencode diff --git a/searx/engines/goodreads.py b/searx/engines/goodreads.py index 7af04ae58..eb5c25605 100644 --- a/searx/engines/goodreads.py +++ b/searx/engines/goodreads.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Goodreads (books) """ diff --git a/searx/engines/google.py b/searx/engines/google.py index 0bf7fdb01..fd59a0e2e 100644 --- a/searx/engines/google.py +++ b/searx/engines/google.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Google WEB engine. Some of this implementations (manly the :py:obj:`get_google_info`) are shared by other engines: diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 31211b9b6..edd386641 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Google Images engine using the internal Google API used by the Google Go Android app. diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index a5ed63bbe..6f5db041e 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Google News engine. Google News has a different region handling compared to Google WEB. diff --git a/searx/engines/google_play.py b/searx/engines/google_play.py index a9cfd1a76..f8ab02c27 100644 --- a/searx/engines/google_play.py +++ b/searx/engines/google_play.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Google Play Apps & Google Play Movies """ diff --git a/searx/engines/google_scholar.py b/searx/engines/google_scholar.py index 8d11c956f..8b47360a8 100644 --- a/searx/engines/google_scholar.py +++ b/searx/engines/google_scholar.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Google Scholar engine. Compared to other Google services the Scholar engine has a simple GET REST-API diff --git a/searx/engines/google_videos.py b/searx/engines/google_videos.py index 334358446..4a5818f7e 100644 --- a/searx/engines/google_videos.py +++ b/searx/engines/google_videos.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Google Videos engine. .. admonition:: Content-Security-Policy (CSP) diff --git a/searx/engines/hackernews.py b/searx/engines/hackernews.py index 4183874f2..a9e29bf0a 100644 --- a/searx/engines/hackernews.py +++ b/searx/engines/hackernews.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Hackernews """ diff --git a/searx/engines/imdb.py b/searx/engines/imdb.py index 0c6f2d5f0..b0938b523 100644 --- a/searx/engines/imdb.py +++ b/searx/engines/imdb.py @@ -1,6 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint - """IMDB - Internet Movie Database Retrieves results from a basic search. Advanced search options are not diff --git a/searx/engines/imgur.py b/searx/engines/imgur.py index 2fe050705..7a4793c58 100644 --- a/searx/engines/imgur.py +++ b/searx/engines/imgur.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Imgur (images) """ diff --git a/searx/engines/internet_archive_scholar.py b/searx/engines/internet_archive_scholar.py index a4f1ddd03..d3956eb71 100644 --- a/searx/engines/internet_archive_scholar.py +++ b/searx/engines/internet_archive_scholar.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Internet Archive scholar(science) """ diff --git a/searx/engines/invidious.py b/searx/engines/invidious.py index 566b0cf98..49f90cc09 100644 --- a/searx/engines/invidious.py +++ b/searx/engines/invidious.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Invidious (Videos) """ diff --git a/searx/engines/json_engine.py b/searx/engines/json_engine.py index 9bf5f5c28..47cf16372 100644 --- a/searx/engines/json_engine.py +++ b/searx/engines/json_engine.py @@ -1,4 +1,15 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +"""The JSON engine is a *generic* engine with which it is possible to configure +engines in the settings. + +.. todo:: + + - The JSON engine needs documentation!! + + - The parameters of the JSON engine should be adapted to those of the XPath + engine. + +""" from collections.abc import Iterable from json import loads @@ -32,32 +43,31 @@ first_page_num = 1 def iterate(iterable): - if type(iterable) == dict: - it = iterable.items() + if isinstance(iterable, dict): + items = iterable.items() else: - it = enumerate(iterable) - for index, value in it: + items = enumerate(iterable) + for index, value in items: yield str(index), value def is_iterable(obj): - if type(obj) == str: + if isinstance(obj, str): return False return isinstance(obj, Iterable) -def parse(query): - q = [] +def parse(query): # pylint: disable=redefined-outer-name + q = [] # pylint: disable=invalid-name for part in query.split('/'): if part == '': continue - else: - q.append(part) + q.append(part) return q -def do_query(data, q): +def do_query(data, q): # pylint: disable=invalid-name ret = [] if not q: return ret @@ -87,10 +97,10 @@ def query(data, query_string): return do_query(data, q) -def request(query, params): +def request(query, params): # pylint: disable=redefined-outer-name query = urlencode({'q': query})[2:] - fp = {'query': query} + fp = {'query': query} # pylint: disable=invalid-name if paging and search_url.find('{pageno}') >= 0: fp['pageno'] = (params['pageno'] - 1) * page_size + first_page_num @@ -115,18 +125,18 @@ def response(resp): content_filter = html_to_text if content_html_to_text else identity if results_query: - rs = query(json, results_query) - if not len(rs): + rs = query(json, results_query) # pylint: disable=invalid-name + if not rs: return results for result in rs[0]: try: url = query(result, url_query)[0] title = query(result, title_query)[0] - except: + except: # pylint: disable=bare-except continue try: content = query(result, content_query)[0] - except: + except: # pylint: disable=bare-except content = "" results.append( { diff --git a/searx/engines/kickass.py b/searx/engines/kickass.py index bda50179b..12bf9c04d 100644 --- a/searx/engines/kickass.py +++ b/searx/engines/kickass.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Kickass Torrent (Videos, Music, Files)""" import random diff --git a/searx/engines/lemmy.py b/searx/engines/lemmy.py index bc3cc9cf6..a924b4bc4 100644 --- a/searx/engines/lemmy.py +++ b/searx/engines/lemmy.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This engine uses the Lemmy API (https://lemmy.ml/api/v3/search), which is documented at `lemmy-js-client`_ / `Interface Search`_. Since Lemmy is federated, results are from many different, independent lemmy instances, and not diff --git a/searx/engines/lib_rs.py b/searx/engines/lib_rs.py index c9435cc2a..79a69d19e 100644 --- a/searx/engines/lib_rs.py +++ b/searx/engines/lib_rs.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """lib.rs (packages)""" from urllib.parse import quote_plus diff --git a/searx/engines/lingva.py b/searx/engines/lingva.py index cc5646050..dac574afa 100644 --- a/searx/engines/lingva.py +++ b/searx/engines/lingva.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Lingva (alternative Google Translate frontend)""" from json import loads diff --git a/searx/engines/livespace.py b/searx/engines/livespace.py index 3f466bbf0..6a9056779 100755 --- a/searx/engines/livespace.py +++ b/searx/engines/livespace.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """LiveSpace (Videos) .. hint:: diff --git a/searx/engines/mastodon.py b/searx/engines/mastodon.py index 1f9d4014f..b7b05cfb5 100644 --- a/searx/engines/mastodon.py +++ b/searx/engines/mastodon.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Mastodon_ is an open source alternative to large social media platforms like Twitter/X, Facebook, ... diff --git a/searx/engines/material_icons.py b/searx/engines/material_icons.py index 68b17f4c6..381cedae1 100644 --- a/searx/engines/material_icons.py +++ b/searx/engines/material_icons.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Material Icons (images) + """ import re diff --git a/searx/engines/mediathekviewweb.py b/searx/engines/mediathekviewweb.py index 5570ebe24..6d2331a3d 100644 --- a/searx/engines/mediathekviewweb.py +++ b/searx/engines/mediathekviewweb.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """MediathekViewWeb (API) """ diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index 6a9ac974a..76317402e 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """The MediaWiki engine is a *generic* engine to **query** Wikimedia wikis by the `MediaWiki Action API`_. For a `query action`_ all Wikimedia wikis have endpoints that follow this pattern:: diff --git a/searx/engines/meilisearch.py b/searx/engines/meilisearch.py index 0c2370216..e22674251 100644 --- a/searx/engines/meilisearch.py +++ b/searx/engines/meilisearch.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """.. sidebar:: info - :origin:`meilisearch.py ` diff --git a/searx/engines/metacpan.py b/searx/engines/metacpan.py index 9d7f539e9..50608bc11 100644 --- a/searx/engines/metacpan.py +++ b/searx/engines/metacpan.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """metacpan """ diff --git a/searx/engines/mixcloud.py b/searx/engines/mixcloud.py index 3f255697e..d6618aa6a 100644 --- a/searx/engines/mixcloud.py +++ b/searx/engines/mixcloud.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Mixcloud (Music) """ diff --git a/searx/engines/mongodb.py b/searx/engines/mongodb.py index 260d6da97..57eaa8537 100644 --- a/searx/engines/mongodb.py +++ b/searx/engines/mongodb.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """MongoDB_ is a document based database program that handles JSON like data. Before configuring the ``mongodb`` engine, you must install the dependency pymongo_. diff --git a/searx/engines/moviepilot.py b/searx/engines/moviepilot.py index f9206c74c..645936d9f 100644 --- a/searx/engines/moviepilot.py +++ b/searx/engines/moviepilot.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Moviepilot is a German movie database, similar to IMDB or TMDB. It doesn't have any official API, but it uses JSON requests internally to fetch search results and suggestions, that's being used in this implementation. diff --git a/searx/engines/mozhi.py b/searx/engines/mozhi.py index 3494e1863..f6fdee566 100644 --- a/searx/engines/mozhi.py +++ b/searx/engines/mozhi.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Mozhi (alternative frontend for popular translation engines)""" import random diff --git a/searx/engines/mrs.py b/searx/engines/mrs.py index 68e34d21d..c4bb54eb8 100644 --- a/searx/engines/mrs.py +++ b/searx/engines/mrs.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Matrix Rooms Search - a fully-featured, standalone, matrix rooms search service. Configuration diff --git a/searx/engines/mullvad_leta.py b/searx/engines/mullvad_leta.py index 121331bf3..6e46163e3 100644 --- a/searx/engines/mullvad_leta.py +++ b/searx/engines/mullvad_leta.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This is the implementation of the Mullvad-Leta meta-search engine. diff --git a/searx/engines/mwmbl.py b/searx/engines/mwmbl.py index f4905401d..01d5e692f 100644 --- a/searx/engines/mwmbl.py +++ b/searx/engines/mwmbl.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Mwmbl_ is a non-profit, ad-free, free-libre and free-lunch search engine with a focus on useability and speed. diff --git a/searx/engines/mysql_server.py b/searx/engines/mysql_server.py index 82bb37f51..369b2b7fe 100644 --- a/searx/engines/mysql_server.py +++ b/searx/engines/mysql_server.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """MySQL is said to be the most popular open source database. Before enabling MySQL engine, you must install the package ``mysql-connector-python``. diff --git a/searx/engines/npm.py b/searx/engines/npm.py index 0fef2dda8..ac21a62b8 100644 --- a/searx/engines/npm.py +++ b/searx/engines/npm.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """npms.io """ diff --git a/searx/engines/nyaa.py b/searx/engines/nyaa.py index 1e9d846be..c22339dbf 100644 --- a/searx/engines/nyaa.py +++ b/searx/engines/nyaa.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Nyaa.si (Anime Bittorrent tracker) """ diff --git a/searx/engines/odysee.py b/searx/engines/odysee.py index 3189ab4c6..595c92b47 100644 --- a/searx/engines/odysee.py +++ b/searx/engines/odysee.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Odysee_ is a decentralized video hosting platform. .. _Odysee: https://github.com/OdyseeTeam/odysee-frontend diff --git a/searx/engines/opensemantic.py b/searx/engines/opensemantic.py index 64bc321f1..03b01df43 100644 --- a/searx/engines/opensemantic.py +++ b/searx/engines/opensemantic.py @@ -1,11 +1,11 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Open Semantic Search +"""Open Semantic Search + """ -from dateutil import parser from json import loads from urllib.parse import quote +from dateutil import parser # about about = { diff --git a/searx/engines/openstreetmap.py b/searx/engines/openstreetmap.py index 68ec0549e..7e3d8f43b 100644 --- a/searx/engines/openstreetmap.py +++ b/searx/engines/openstreetmap.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """OpenStreetMap (Map) """ diff --git a/searx/engines/pdbe.py b/searx/engines/pdbe.py index a0526057d..96e3509c2 100644 --- a/searx/engines/pdbe.py +++ b/searx/engines/pdbe.py @@ -96,7 +96,7 @@ def response(resp): title = gettext('{title} (OBSOLETE)').format(title=result['title']) try: superseded_url = pdbe_entry_url.format(pdb_id=result['superseded_by']) - except: + except: # pylint: disable=bare-except continue # since we can't construct a proper body from the response, we'll make up our own diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py index d0eba6b88..114e24c4f 100644 --- a/searx/engines/peertube.py +++ b/searx/engines/peertube.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Peertube and :py:obj:`SepiaSearch ` do share (more or less) the same REST API and the schema of the JSON result is identical. diff --git a/searx/engines/photon.py b/searx/engines/photon.py index 2ea393679..43c41bf46 100644 --- a/searx/engines/photon.py +++ b/searx/engines/photon.py @@ -87,7 +87,7 @@ def response(resp): properties.get('extent')[2], ] else: - # TODO: better boundingbox calculation + # better boundingbox calculation? boundingbox = [ geojson['coordinates'][1], geojson['coordinates'][1], diff --git a/searx/engines/pinterest.py b/searx/engines/pinterest.py index 756c1b8e0..841b98ba0 100644 --- a/searx/engines/pinterest.py +++ b/searx/engines/pinterest.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Pinterest (images) """ diff --git a/searx/engines/piped.py b/searx/engines/piped.py index 5b4cbded3..09ef48fe6 100644 --- a/searx/engines/piped.py +++ b/searx/engines/piped.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """An alternative privacy-friendly YouTube frontend which is efficient by design. `Piped’s architecture`_ consists of 3 components: diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py index 4b0984be5..ba58e64fc 100644 --- a/searx/engines/piratebay.py +++ b/searx/engines/piratebay.py @@ -82,14 +82,14 @@ def response(resp): try: date = datetime.fromtimestamp(float(result["added"])) params['publishedDate'] = date - except: + except: # pylint: disable=bare-except pass # let's try to calculate the torrent size try: filesize = get_torrent_size(result["size"], "B") params['filesize'] = filesize - except: + except: # pylint: disable=bare-except pass # append result diff --git a/searx/engines/pixiv.py b/searx/engines/pixiv.py index fdb74e818..abf316228 100644 --- a/searx/engines/pixiv.py +++ b/searx/engines/pixiv.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Pixiv (images)""" from urllib.parse import urlencode diff --git a/searx/engines/pkg_go_dev.py b/searx/engines/pkg_go_dev.py index dcbd88451..60d65fd4f 100644 --- a/searx/engines/pkg_go_dev.py +++ b/searx/engines/pkg_go_dev.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """pkg.go.dev (packages)""" import re diff --git a/searx/engines/podcastindex.py b/searx/engines/podcastindex.py index 7f1e2cd02..d0aa85fb8 100644 --- a/searx/engines/podcastindex.py +++ b/searx/engines/podcastindex.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Podcast Index """ diff --git a/searx/engines/postgresql.py b/searx/engines/postgresql.py index c0277207c..e7def0635 100644 --- a/searx/engines/postgresql.py +++ b/searx/engines/postgresql.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """PostgreSQL is a powerful and robust open source database. Before configuring the PostgreSQL engine, you must install the dependency ``psychopg2``. diff --git a/searx/engines/presearch.py b/searx/engines/presearch.py index baf692d60..88fa59f0e 100644 --- a/searx/engines/presearch.py +++ b/searx/engines/presearch.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Presearch supports the search types listed in :py:obj:`search_type` (general, images, videos, news). diff --git a/searx/engines/pubmed.py b/searx/engines/pubmed.py index b6ffd039f..be934cdc8 100644 --- a/searx/engines/pubmed.py +++ b/searx/engines/pubmed.py @@ -1,11 +1,12 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - PubMed (Scholar publications) +"""PubMed (Scholar publications) + """ -from lxml import etree from datetime import datetime from urllib.parse import urlencode + +from lxml import etree from searx.network import get from searx.utils import ( eval_xpath_getindex, @@ -41,14 +42,18 @@ def request(query, params): # basic search offset = (params['pageno'] - 1) * number_of_results - string_args = dict(query=urlencode({'term': query}), offset=offset, hits=number_of_results) + string_args = { + 'query': urlencode({'term': query}), + 'offset': offset, + 'hits': number_of_results, + } params['url'] = base_url.format(**string_args) return params -def response(resp): +def response(resp): # pylint: disable=too-many-locals results = [] # First retrieve notice of each result @@ -63,7 +68,7 @@ def response(resp): for item in pmids: pmids_string += item.text + ',' - retrieve_notice_args = dict(pmids_string=pmids_string) + retrieve_notice_args = {'pmids_string': pmids_string} retrieve_url_encoded = pubmed_retrieve_api_url.format(**retrieve_notice_args) @@ -119,7 +124,7 @@ def response(resp): '%Y-%m-%d', ) res_dict['publishedDate'] = publishedDate - except Exception as e: + except Exception as e: # pylint: disable=broad-exception-caught print(e) results.append(res_dict) diff --git a/searx/engines/pypi.py b/searx/engines/pypi.py index e49de11e5..7ebb254f3 100644 --- a/searx/engines/pypi.py +++ b/searx/engines/pypi.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """pypi.org """ diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 775a11292..46edb6958 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This engine uses the Qwant API (https://api.qwant.com/v3) to implement Qwant -Web, -News, -Images and -Videos. The API is undocumented but can be reverse engineered by reading the network log of https://www.qwant.com/ queries. diff --git a/searx/engines/radio_browser.py b/searx/engines/radio_browser.py index 6b60b398e..3c06159a2 100644 --- a/searx/engines/radio_browser.py +++ b/searx/engines/radio_browser.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Search radio stations from RadioBrowser by `Advanced station search API`_. .. _Advanced station search API: diff --git a/searx/engines/recoll.py b/searx/engines/recoll.py index c11e197ed..b9e87a723 100644 --- a/searx/engines/recoll.py +++ b/searx/engines/recoll.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """.. sidebar:: info - `Recoll `_ diff --git a/searx/engines/reddit.py b/searx/engines/reddit.py index 36d92339d..263b70b73 100644 --- a/searx/engines/reddit.py +++ b/searx/engines/reddit.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Reddit + """ import json diff --git a/searx/engines/redis_server.py b/searx/engines/redis_server.py index 980812509..3268378c6 100644 --- a/searx/engines/redis_server.py +++ b/searx/engines/redis_server.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Redis is an open source (BSD licensed), in-memory data structure (key value based) store. Before configuring the ``redis_server`` engine, you must install the dependency redis_. diff --git a/searx/engines/rottentomatoes.py b/searx/engines/rottentomatoes.py index 727287355..0cac6e247 100644 --- a/searx/engines/rottentomatoes.py +++ b/searx/engines/rottentomatoes.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """RottenTomatoes (movies) """ diff --git a/searx/engines/rumble.py b/searx/engines/rumble.py index e4a50c732..5267e04c0 100644 --- a/searx/engines/rumble.py +++ b/searx/engines/rumble.py @@ -1,10 +1,12 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +"""Rumble (Videos) + """ - Rumble (Videos) -""" + +from datetime import datetime + from urllib.parse import urlencode from lxml import html -from datetime import datetime # about from searx.utils import extract_text diff --git a/searx/engines/searchcode_code.py b/searx/engines/searchcode_code.py index a53c72094..7cfe2ce71 100644 --- a/searx/engines/searchcode_code.py +++ b/searx/engines/searchcode_code.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Searchcode (IT) """ diff --git a/searx/engines/searx_engine.py b/searx/engines/searx_engine.py index 84a8e6449..156001997 100644 --- a/searx/engines/searx_engine.py +++ b/searx/engines/searx_engine.py @@ -25,7 +25,7 @@ instance_index = 0 # do search-request def request(query, params): - global instance_index + global instance_index # pylint: disable=global-statement params['url'] = instance_urls[instance_index % len(instance_urls)] params['method'] = 'POST' diff --git a/searx/engines/seekr.py b/searx/engines/seekr.py index 014b736dc..967eef86d 100644 --- a/searx/engines/seekr.py +++ b/searx/engines/seekr.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """seekr.com Seeker Score Seekr is a privately held search and content evaluation engine that prioritizes diff --git a/searx/engines/semantic_scholar.py b/searx/engines/semantic_scholar.py index 7838a7d55..cc65ff542 100644 --- a/searx/engines/semantic_scholar.py +++ b/searx/engines/semantic_scholar.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Semantic Scholar (Science) """ diff --git a/searx/engines/sepiasearch.py b/searx/engines/sepiasearch.py index 72157b253..76376277e 100644 --- a/searx/engines/sepiasearch.py +++ b/searx/engines/sepiasearch.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """SepiaSearch uses the same languages as :py:obj:`Peertube ` and the response is identical to the response from the peertube engines. diff --git a/searx/engines/seznam.py b/searx/engines/seznam.py index 36a38848a..d480956bd 100644 --- a/searx/engines/seznam.py +++ b/searx/engines/seznam.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Seznam """ diff --git a/searx/engines/sjp.py b/searx/engines/sjp.py index 711fed736..639420095 100644 --- a/searx/engines/sjp.py +++ b/searx/engines/sjp.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Słownik Języka Polskiego Dictionary of the polish language from PWN (sjp.pwn) diff --git a/searx/engines/solidtorrents.py b/searx/engines/solidtorrents.py index b853d9e25..3cad8e549 100644 --- a/searx/engines/solidtorrents.py +++ b/searx/engines/solidtorrents.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """SolidTorrents + """ from datetime import datetime diff --git a/searx/engines/solr.py b/searx/engines/solr.py index 85ed42cf9..4b80d5729 100644 --- a/searx/engines/solr.py +++ b/searx/engines/solr.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """.. sidebar:: info - :origin:`solr.py ` diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py index 78947c69c..3181d39b7 100644 --- a/searx/engines/soundcloud.py +++ b/searx/engines/soundcloud.py @@ -5,9 +5,9 @@ import re from json import loads +from urllib.parse import quote_plus, urlencode from lxml import html from dateutil import parser -from urllib.parse import quote_plus, urlencode from searx.network import get as http_get # about @@ -42,10 +42,10 @@ guest_client_id = '' def get_client_id(): - response = http_get("https://soundcloud.com") + resp = http_get("https://soundcloud.com") - if response.ok: - tree = html.fromstring(response.content) + if resp.ok: + tree = html.fromstring(resp.content) # script_tags has been moved from /assets/app/ to /assets/ path. I # found client_id in https://a-v2.sndcdn.com/assets/49-a0c01933-3.js script_tags = tree.xpath("//script[contains(@src, '/assets/')]") @@ -54,17 +54,17 @@ def get_client_id(): # extracts valid app_js urls from soundcloud.com content for app_js_url in app_js_urls[::-1]: # gets app_js and searches for the clientid - response = http_get(app_js_url) - if response.ok: - cids = cid_re.search(response.content.decode()) + resp = http_get(app_js_url) + if resp.ok: + cids = cid_re.search(resp.content.decode()) if cids is not None and len(cids.groups()): return cids.groups()[0] logger.warning("Unable to fetch guest client_id from SoundCloud, check parser!") return "" -def init(engine_settings=None): - global guest_client_id +def init(engine_settings=None): # pylint: disable=unused-argument + global guest_client_id # pylint: disable=global-statement # api-key guest_client_id = get_client_id() @@ -78,7 +78,6 @@ def request(query, params): return params -# get response from search-request def response(resp): results = [] search_res = loads(resp.text) diff --git a/searx/engines/spotify.py b/searx/engines/spotify.py index 491a7058e..3b86328b7 100644 --- a/searx/engines/spotify.py +++ b/searx/engines/spotify.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Spotify (Music) +"""Spotify (Music) + """ from json import loads @@ -60,13 +60,13 @@ def response(resp): for result in search_res.get('tracks', {}).get('items', {}): if result['type'] == 'track': title = result['name'] - url = result['external_urls']['spotify'] + link = result['external_urls']['spotify'] content = '{} - {} - {}'.format(result['artists'][0]['name'], result['album']['name'], result['name']) # append result results.append( { - 'url': url, + 'url': link, 'title': title, 'iframe_src': "https://embed.spotify.com/?uri=spotify:track:" + result['id'], 'content': content, diff --git a/searx/engines/springer.py b/searx/engines/springer.py index a4d0832d8..ba59fa926 100644 --- a/searx/engines/springer.py +++ b/searx/engines/springer.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Springer Nature (science) """ diff --git a/searx/engines/sqlite.py b/searx/engines/sqlite.py index 76e83af8a..f5f6ac8bf 100644 --- a/searx/engines/sqlite.py +++ b/searx/engines/sqlite.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """SQLite is a small, fast and reliable SQL database engine. It does not require any extra dependency. diff --git a/searx/engines/stackexchange.py b/searx/engines/stackexchange.py index 99615b1a7..02e0d477a 100644 --- a/searx/engines/stackexchange.py +++ b/searx/engines/stackexchange.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Stack Exchange API v2.3 * https://api.stackexchange.com/ diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index 15ebc6d0b..aa594f0dc 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Startpage's language & region selectors are a mess .. .. _startpage regions: diff --git a/searx/engines/stract.py b/searx/engines/stract.py index c2497998f..2ba26e756 100644 --- a/searx/engines/stract.py +++ b/searx/engines/stract.py @@ -1,7 +1,8 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint -"""Stract is an independent open source search engine. -At this state, it's still in beta and hence this implementation will need to be updated once beta ends. +"""Stract is an independent open source search engine. At this state, it's +still in beta and hence this implementation will need to be updated once beta +ends. + """ from json import dumps diff --git a/searx/engines/svgrepo.py b/searx/engines/svgrepo.py index 19c37ff58..156f4b2a8 100644 --- a/searx/engines/svgrepo.py +++ b/searx/engines/svgrepo.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Svgrepo (images) """ diff --git a/searx/engines/tagesschau.py b/searx/engines/tagesschau.py index cfa184025..58bd40e56 100644 --- a/searx/engines/tagesschau.py +++ b/searx/engines/tagesschau.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """ARD: `Tagesschau API`_ The Tagesschau is a news program of the ARD. Via the `Tagesschau API`_, current diff --git a/searx/engines/tineye.py b/searx/engines/tineye.py index 6c5ff134c..196c89a2b 100644 --- a/searx/engines/tineye.py +++ b/searx/engines/tineye.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This engine implements *Tineye - reverse image search* Using TinEye, you can search by image or perform what we call a reverse image diff --git a/searx/engines/tokyotoshokan.py b/searx/engines/tokyotoshokan.py index b01de38c1..33f036428 100644 --- a/searx/engines/tokyotoshokan.py +++ b/searx/engines/tokyotoshokan.py @@ -1,12 +1,13 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Tokyo Toshokan (A BitTorrent Library for Japanese Media) +"""Tokyo Toshokan (A BitTorrent Library for Japanese Media) + """ import re -from urllib.parse import urlencode -from lxml import html from datetime import datetime +from urllib.parse import urlencode + +from lxml import html from searx.utils import extract_text, get_torrent_size, int_or_zero # about @@ -75,14 +76,14 @@ def response(resp): # ('1.228', 'GB') groups = size_re.match(item).groups() params['filesize'] = get_torrent_size(groups[0], groups[1]) - except: + except: # pylint: disable=bare-except pass elif item.startswith('Date:'): try: # Date: 2016-02-21 21:44 UTC date = datetime.strptime(item, 'Date: %Y-%m-%d %H:%M UTC') params['publishedDate'] = date - except: + except: # pylint: disable=bare-except pass elif item.startswith('Comment:'): params['content'] = item diff --git a/searx/engines/tootfinder.py b/searx/engines/tootfinder.py index b754e15a5..806a7d688 100644 --- a/searx/engines/tootfinder.py +++ b/searx/engines/tootfinder.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Tootfinder (social media) """ diff --git a/searx/engines/torznab.py b/searx/engines/torznab.py index 101cab9e3..70ba78ab4 100644 --- a/searx/engines/torznab.py +++ b/searx/engines/torznab.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Torznab_ is an API specification that provides a standardized way to query torrent site for content. It is used by a number of torrent applications, including Prowlarr_ and Jackett_. diff --git a/searx/engines/translated.py b/searx/engines/translated.py index 9900c017b..105a1d717 100644 --- a/searx/engines/translated.py +++ b/searx/engines/translated.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - MyMemory Translated +"""MyMemory Translated + """ # about @@ -23,7 +23,7 @@ https_support = True api_key = '' -def request(query, params): +def request(query, params): # pylint: disable=unused-argument if api_key: key_form = '&key=' + api_key else: diff --git a/searx/engines/unsplash.py b/searx/engines/unsplash.py index 1967fefd2..998013f57 100644 --- a/searx/engines/unsplash.py +++ b/searx/engines/unsplash.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Unsplash """ diff --git a/searx/engines/voidlinux.py b/searx/engines/voidlinux.py index 608402d13..0d807ace4 100644 --- a/searx/engines/voidlinux.py +++ b/searx/engines/voidlinux.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """SearXNG engine for `Void Linux binary packages`_. Void is a general purpose operating system, based on the monolithic Linux kernel. Its package system allows you to quickly install, update and remove software; software is provided diff --git a/searx/engines/wallhaven.py b/searx/engines/wallhaven.py index 94be1a6a7..127873d5d 100644 --- a/searx/engines/wallhaven.py +++ b/searx/engines/wallhaven.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Wallhaven_ is a site created by and for people who like wallpapers. .. _Wallhaven: https://wallhaven.cc/about#Copyright diff --git a/searx/engines/wikicommons.py b/searx/engines/wikicommons.py index 9b0849716..0bb140abc 100644 --- a/searx/engines/wikicommons.py +++ b/searx/engines/wikicommons.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Wikimedia Commons (images) """ diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 8fa3a97d3..268da6fa9 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This module implements the Wikidata engine. Some implementations are shared from :ref:`wikipedia engine`. diff --git a/searx/engines/wikipedia.py b/searx/engines/wikipedia.py index d825cbdea..187915d65 100644 --- a/searx/engines/wikipedia.py +++ b/searx/engines/wikipedia.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """This module implements the Wikipedia engine. Some of this implementations are shared by other engines: diff --git a/searx/engines/wolframalpha_api.py b/searx/engines/wolframalpha_api.py index 6a2423b51..5670e356f 100644 --- a/searx/engines/wolframalpha_api.py +++ b/searx/engines/wolframalpha_api.py @@ -1,11 +1,12 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Wolfram|Alpha (Science) +"""Wolfram|Alpha (Science) + """ -from lxml import etree from urllib.parse import urlencode +from lxml import etree + # about about = { "website": 'https://www.wolframalpha.com', @@ -79,7 +80,7 @@ def response(resp): try: infobox_title = search_results.xpath(input_xpath)[0].text - except: + except: # pylint: disable=bare-except infobox_title = "" pods = search_results.xpath(pods_xpath) diff --git a/searx/engines/wolframalpha_noapi.py b/searx/engines/wolframalpha_noapi.py index bad25602a..a9d177c32 100644 --- a/searx/engines/wolframalpha_noapi.py +++ b/searx/engines/wolframalpha_noapi.py @@ -54,12 +54,12 @@ def obtain_token(): token_response = http_get('https://www.wolframalpha.com/input/api/v1/code?ts=9999999999999999999', timeout=2.0) token['value'] = loads(token_response.text)['code'] token['last_updated'] = update_time - except: + except: # pylint: disable=bare-except pass return token -def init(engine_settings=None): +def init(engine_settings=None): # pylint: disable=unused-argument obtain_token() @@ -83,7 +83,7 @@ def response(resp): if not resp_json['queryresult']['success']: return [] - # TODO handle resp_json['queryresult']['assumptions'] + # handle resp_json['queryresult']['assumptions']? result_chunks = [] infobox_title = "" result_content = "" diff --git a/searx/engines/wttr.py b/searx/engines/wttr.py index 2eaee62ae..11a2d27cc 100644 --- a/searx/engines/wttr.py +++ b/searx/engines/wttr.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """wttr.in (weather forecast service)""" from json import loads diff --git a/searx/engines/www1x.py b/searx/engines/www1x.py index a7ec06f18..0d4b6b799 100644 --- a/searx/engines/www1x.py +++ b/searx/engines/www1x.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """1x (Images) """ diff --git a/searx/engines/xpath.py b/searx/engines/xpath.py index 442e90595..bdad7e753 100644 --- a/searx/engines/xpath.py +++ b/searx/engines/xpath.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """The XPath engine is a *generic* engine with which it is possible to configure engines in the settings. diff --git a/searx/engines/yacy.py b/searx/engines/yacy.py index 50c7886c0..3a0414787 100644 --- a/searx/engines/yacy.py +++ b/searx/engines/yacy.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """YaCy_ is a free distributed search engine, built on the principles of peer-to-peer (P2P) networks. diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.py index 53dc6f806..d5edde212 100644 --- a/searx/engines/yahoo.py +++ b/searx/engines/yahoo.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Yahoo Search (Web) Languages are supported by mapping the language to a domain. If domain is not diff --git a/searx/engines/yahoo_news.py b/searx/engines/yahoo_news.py index 00f208b17..f3f756ba3 100644 --- a/searx/engines/yahoo_news.py +++ b/searx/engines/yahoo_news.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Yahoo (News) Yahoo News is "English only" and do not offer localized nor language queries. diff --git a/searx/engines/yandex_music.py b/searx/engines/yandex_music.py index 5d6fe6bb1..810654b6f 100644 --- a/searx/engines/yandex_music.py +++ b/searx/engines/yandex_music.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Yandex Music .. _Countries where Yandex.Music is available: https://yandex.com/support/music/access.html diff --git a/searx/engines/yep.py b/searx/engines/yep.py index c3cb65c7b..e01e31c8c 100644 --- a/searx/engines/yep.py +++ b/searx/engines/yep.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Yep (general, images, news) """ diff --git a/searx/engines/youtube_api.py b/searx/engines/youtube_api.py index 1b332a9f7..25ad2cb04 100644 --- a/searx/engines/youtube_api.py +++ b/searx/engines/youtube_api.py @@ -4,8 +4,9 @@ """ from json import loads -from dateutil import parser from urllib.parse import urlencode + +from dateutil import parser from searx.exceptions import SearxEngineAPIException # about diff --git a/searx/engines/youtube_noapi.py b/searx/engines/youtube_noapi.py index 7992adf82..b015dff8d 100644 --- a/searx/engines/youtube_noapi.py +++ b/searx/engines/youtube_noapi.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Youtube (Videos) +"""Youtube (Videos) + """ from functools import reduce @@ -101,7 +101,7 @@ def parse_next_page_response(response_text): "key": "next_page_token", } ) - except: + except: # pylint: disable=bare-except pass return results @@ -167,5 +167,4 @@ def parse_first_page_response(response_text): def get_text_from_json(element): if 'runs' in element: return reduce(lambda a, b: a + b.get('text', ''), element.get('runs'), '') - else: - return element.get('simpleText', '') + return element.get('simpleText', '') diff --git a/searx/engines/yummly.py b/searx/engines/yummly.py index 25285ef7c..fcafcc651 100644 --- a/searx/engines/yummly.py +++ b/searx/engines/yummly.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """Yummly """ diff --git a/searx/engines/zlibrary.py b/searx/engines/zlibrary.py index dd32004f7..ba1f474fa 100644 --- a/searx/engines/zlibrary.py +++ b/searx/engines/zlibrary.py @@ -1,5 +1,4 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -# lint: pylint """`Z-Library`_ (abbreviated as z-lib, formerly BookFinder) is a shadow library project for file-sharing access to scholarly journal articles, academic texts and general-interest books. It began as a mirror of Library Genesis, from which diff --git a/utils/lib_sxng_test.sh b/utils/lib_sxng_test.sh old mode 100644 new mode 100755 index 41a20d86f..1bba9aa4c --- a/utils/lib_sxng_test.sh +++ b/utils/lib_sxng_test.sh @@ -1,3 +1,8 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: AGPL-3.0-or-later + +[[ -z "${PYLINT_OPTIONS}" ]] && PYLINT_OPTIONS="-j 0 --rcfile .pylintrc" + test.help(){ cat <