From 3038052c79ed16d4e32be9680b426b7a765f4f01 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 2 Nov 2020 11:19:53 +0100 Subject: [PATCH] [mod] remove unused import use from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA so it is possible to easily remove all unused import using autoflake: autoflake --in-place --recursive --remove-all-unused-imports searx tests --- searx/engines/acgsou.py | 2 +- searx/engines/arxiv.py | 1 - searx/engines/bing.py | 5 ++--- searx/engines/bing_images.py | 4 ++-- searx/engines/bing_news.py | 3 ++- searx/engines/bing_videos.py | 3 ++- searx/engines/btdigg.py | 1 - searx/engines/command.py | 1 - searx/engines/currency_convert.py | 5 +---- searx/engines/deviantart.py | 1 - searx/engines/digg.py | 2 -- searx/engines/duckduckgo.py | 2 -- searx/engines/duckduckgo_definitions.py | 4 ++-- searx/engines/duckduckgo_images.py | 7 ++----- searx/engines/duden.py | 1 - searx/engines/elasticsearch.py | 3 --- searx/engines/google_images.py | 5 +---- searx/engines/google_news.py | 2 +- searx/engines/google_videos.py | 1 - searx/engines/piratebay.py | 4 ++-- searx/engines/soundcloud.py | 1 - searx/engines/startpage.py | 1 - searx/engines/wikidata.py | 2 +- searx/engines/yahoo_news.py | 5 ++--- searx/engines/youtube_noapi.py | 1 - searx/plugins/__init__.py | 1 - searx/results.py | 1 - searx/utils.py | 2 +- searx/webapp.py | 2 +- tests/unit/engines/test_command.py | 1 - tests/unit/test_webadapter.py | 2 +- 31 files changed, 24 insertions(+), 52 deletions(-) diff --git a/searx/engines/acgsou.py b/searx/engines/acgsou.py index 7bab64f5b..553b49b69 100644 --- a/searx/engines/acgsou.py +++ b/searx/engines/acgsou.py @@ -11,7 +11,7 @@ from urllib.parse import urlencode from lxml import html -from searx.utils import extract_text, get_torrent_size, int_or_zero +from searx.utils import extract_text, get_torrent_size # engine dependent config categories = ['files', 'images', 'videos', 'music'] diff --git a/searx/engines/arxiv.py b/searx/engines/arxiv.py index 77ddc572e..e54de4a58 100644 --- a/searx/engines/arxiv.py +++ b/searx/engines/arxiv.py @@ -11,7 +11,6 @@ More info on api: https://arxiv.org/help/api/user-manual """ -from urllib.parse import urlencode from lxml import html from datetime import datetime diff --git a/searx/engines/bing.py b/searx/engines/bing.py index a4fa1db78..f0882fcc9 100644 --- a/searx/engines/bing.py +++ b/searx/engines/bing.py @@ -16,8 +16,8 @@ import re from urllib.parse import urlencode from lxml import html -from searx import logger, utils -from searx.utils import extract_text, match_language, gen_useragent, eval_xpath +from searx import logger +from searx.utils import eval_xpath, extract_text, match_language logger = logger.getChild('bing engine') @@ -98,7 +98,6 @@ def response(resp): result_len = int(result_len_container) except Exception as e: logger.debug('result error :\n%s', e) - pass if result_len and _get_offset_from_pageno(resp.search_params.get("pageno", 0)) > result_len: return [] diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index 10da42b5c..3085e1deb 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -15,10 +15,10 @@ from urllib.parse import urlencode from lxml import html from json import loads -import re from searx.utils import match_language -from searx.engines.bing import _fetch_supported_languages, supported_languages_url, language_aliases +from searx.engines.bing import language_aliases +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA # engine dependent config categories = ['images'] diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py index fbe51faed..aeef7d19a 100644 --- a/searx/engines/bing_news.py +++ b/searx/engines/bing_news.py @@ -16,7 +16,8 @@ from dateutil import parser from urllib.parse import urlencode, urlparse, parse_qsl from lxml import etree from searx.utils import list_get, match_language -from searx.engines.bing import _fetch_supported_languages, supported_languages_url, language_aliases +from searx.engines.bing import language_aliases +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA # engine dependent config categories = ['news'] diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py index 63264de6f..4393ea590 100644 --- a/searx/engines/bing_videos.py +++ b/searx/engines/bing_videos.py @@ -15,7 +15,8 @@ from lxml import html from urllib.parse import urlencode from searx.utils import match_language -from searx.engines.bing import _fetch_supported_languages, supported_languages_url, language_aliases +from searx.engines.bing import language_aliases +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA categories = ['videos'] paging = True diff --git a/searx/engines/btdigg.py b/searx/engines/btdigg.py index d73ee23a6..72bda8d20 100644 --- a/searx/engines/btdigg.py +++ b/searx/engines/btdigg.py @@ -11,7 +11,6 @@ """ from lxml import html -from operator import itemgetter from urllib.parse import quote, urljoin from searx.utils import extract_text, get_torrent_size diff --git a/searx/engines/command.py b/searx/engines/command.py index 1b73861f7..08ee5da06 100644 --- a/searx/engines/command.py +++ b/searx/engines/command.py @@ -18,7 +18,6 @@ import re from os.path import expanduser, isabs, realpath, commonprefix from shlex import split as shlex_split from subprocess import Popen, PIPE -from time import time from threading import Thread from searx import logger diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 4a82cfdca..0e91d31e9 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -1,10 +1,7 @@ import json import re import unicodedata - -from datetime import datetime - -from searx.data import CURRENCIES +from searx.data import CURRENCIES # NOQA categories = [] diff --git a/searx/engines/deviantart.py b/searx/engines/deviantart.py index b91816daa..c06a79b79 100644 --- a/searx/engines/deviantart.py +++ b/searx/engines/deviantart.py @@ -15,7 +15,6 @@ from lxml import html import re from urllib.parse import urlencode -from searx.utils import extract_text # engine dependent config diff --git a/searx/engines/digg.py b/searx/engines/digg.py index 24a932d53..831d698bc 100644 --- a/searx/engines/digg.py +++ b/searx/engines/digg.py @@ -12,10 +12,8 @@ import random import string -from dateutil import parser from json import loads from urllib.parse import urlencode -from lxml import html from datetime import datetime # engine dependent config diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index a53972325..21cd926aa 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -15,8 +15,6 @@ from lxml.html import fromstring from json import loads -from urllib.parse import urlencode -from searx.poolrequests import get from searx.utils import extract_text, match_language, eval_xpath # engine dependent config diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py index f8bc44e46..5758022d2 100644 --- a/searx/engines/duckduckgo_definitions.py +++ b/searx/engines/duckduckgo_definitions.py @@ -15,11 +15,11 @@ from lxml import html from searx import logger from searx.data import WIKIDATA_UNITS -from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url, language_aliases +from searx.engines.duckduckgo import language_aliases +from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA from searx.utils import extract_text, html_to_text, match_language, get_string_replaces_function from searx.external_urls import get_external_url, get_earth_coordinates_url, area_to_osm_zoom - logger = logger.getChild('duckduckgo_definitions') URL = 'https://api.duckduckgo.com/'\ diff --git a/searx/engines/duckduckgo_images.py b/searx/engines/duckduckgo_images.py index 27ef7442e..943b74880 100644 --- a/searx/engines/duckduckgo_images.py +++ b/searx/engines/duckduckgo_images.py @@ -15,12 +15,9 @@ from json import loads from urllib.parse import urlencode -from searx.engines.duckduckgo import ( - _fetch_supported_languages, supported_languages_url, - get_region_code, language_aliases -) +from searx.engines.duckduckgo import get_region_code +from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA from searx.poolrequests import get -from searx.utils import extract_text # engine dependent config categories = ['images'] diff --git a/searx/engines/duden.py b/searx/engines/duden.py index bbe11de9b..1484a21e5 100644 --- a/searx/engines/duden.py +++ b/searx/engines/duden.py @@ -60,7 +60,6 @@ def response(resp): except: logger.debug("Couldn't read number of results.") - pass for result in eval_xpath(dom, '//section[not(contains(@class, "essay"))]'): try: diff --git a/searx/engines/elasticsearch.py b/searx/engines/elasticsearch.py index bad65fb27..99e93d876 100644 --- a/searx/engines/elasticsearch.py +++ b/searx/engines/elasticsearch.py @@ -1,8 +1,5 @@ from json import loads, dumps -from lxml import html -from urllib.parse import quote, urljoin from requests.auth import HTTPBasicAuth -from searx.utils import extract_text, get_torrent_size base_url = 'http://localhost:9200' diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 8cfb1e17f..9669d81c3 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -29,12 +29,9 @@ from lxml import html from flask_babel import gettext from searx import logger from searx.utils import extract_text, eval_xpath +from searx.engines.google import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import -from searx.engines.google import ( - supported_languages_url, - _fetch_supported_languages, -) # pylint: enable=unused-import from searx.engines.google import ( diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index 08875328c..6cfc0c8e7 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -12,8 +12,8 @@ from urllib.parse import urlencode from lxml import html -from searx.engines.google import _fetch_supported_languages, supported_languages_url from searx.utils import match_language +from searx.engines.google import _fetch_supported_languages, supported_languages_url # NOQA # search-url categories = ['news'] diff --git a/searx/engines/google_videos.py b/searx/engines/google_videos.py index 78e1eb1cb..1e6c8b3ee 100644 --- a/searx/engines/google_videos.py +++ b/searx/engines/google_videos.py @@ -11,7 +11,6 @@ """ from datetime import date, timedelta -from json import loads from urllib.parse import urlencode from lxml import html from searx.utils import extract_text diff --git a/searx/engines/piratebay.py b/searx/engines/piratebay.py index b56b92a24..828241ece 100644 --- a/searx/engines/piratebay.py +++ b/searx/engines/piratebay.py @@ -12,8 +12,8 @@ from json import loads from datetime import datetime from operator import itemgetter -from urllib.parse import quote, urljoin -from searx.utils import extract_text, get_torrent_size +from urllib.parse import quote +from searx.utils import get_torrent_size # engine dependent config categories = ["videos", "music", "files"] diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py index 5165ea3ea..b1e01759f 100644 --- a/searx/engines/soundcloud.py +++ b/searx/engines/soundcloud.py @@ -14,7 +14,6 @@ import re from json import loads from lxml import html from dateutil import parser -from io import StringIO from urllib.parse import quote_plus, urlencode from searx import logger from searx.poolrequests import get as http_get diff --git a/searx/engines/startpage.py b/searx/engines/startpage.py index d26c2d105..90ed0a7a1 100644 --- a/searx/engines/startpage.py +++ b/searx/engines/startpage.py @@ -17,7 +17,6 @@ import re from unicodedata import normalize, combining from babel import Locale from babel.localedata import locale_identifiers -from searx.languages import language_codes from searx.utils import extract_text, eval_xpath, match_language # engine dependent config diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 01e873de9..3d8daca5d 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -21,9 +21,9 @@ from babel.dates import format_datetime, format_date, format_time, get_datetime_ from searx import logger from searx.data import WIKIDATA_UNITS from searx.poolrequests import post, get -from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url from searx.utils import match_language, searx_useragent, get_string_replaces_function from searx.external_urls import get_external_url, get_earth_coordinates_url, area_to_osm_zoom +from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url # NOQA logger = logger.getChild('wikidata') diff --git a/searx/engines/yahoo_news.py b/searx/engines/yahoo_news.py index e9dd5d6db..11941cfe1 100644 --- a/searx/engines/yahoo_news.py +++ b/searx/engines/yahoo_news.py @@ -13,9 +13,8 @@ import re from datetime import datetime, timedelta from urllib.parse import urlencode from lxml import html -from searx.engines.yahoo import ( - parse_url, _fetch_supported_languages, supported_languages_url, language_aliases -) +from searx.engines.yahoo import parse_url, language_aliases +from searx.engines.yahoo import _fetch_supported_languages, supported_languages_url # NOQA from dateutil import parser from searx.utils import extract_text, extract_url, match_language diff --git a/searx/engines/youtube_noapi.py b/searx/engines/youtube_noapi.py index 16c0eddeb..5f7d2ceab 100644 --- a/searx/engines/youtube_noapi.py +++ b/searx/engines/youtube_noapi.py @@ -11,7 +11,6 @@ from functools import reduce from json import loads from urllib.parse import quote_plus -from searx.utils import extract_text, list_get # engine dependent config categories = ['videos', 'music'] diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 8221f7c1d..fe7ae0578 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -20,7 +20,6 @@ from importlib import import_module from os import listdir, makedirs, remove, stat, utime from os.path import abspath, basename, dirname, exists, join from shutil import copyfile -from traceback import print_exc from searx import logger, settings, static_path diff --git a/searx/results.py b/searx/results.py index 34a94511a..e0bbe3358 100644 --- a/searx/results.py +++ b/searx/results.py @@ -1,5 +1,4 @@ import re -from collections import defaultdict from operator import itemgetter from threading import RLock from urllib.parse import urlparse, unquote diff --git a/searx/utils.py b/searx/utils.py index 9e43c67f0..4eed87f21 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -7,7 +7,7 @@ from numbers import Number from os.path import splitext, join from random import choice from html.parser import HTMLParser -from urllib.parse import urljoin, urlparse, unquote +from urllib.parse import urljoin, urlparse from lxml import html from lxml.etree import XPath, _ElementStringResult, _ElementUnicodeResult diff --git a/searx/webapp.py b/searx/webapp.py index 326200cec..65308275b 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -40,7 +40,7 @@ from datetime import datetime, timedelta from time import time from html import escape from io import StringIO -from urllib.parse import urlencode, urlparse, urljoin, urlsplit +from urllib.parse import urlencode, urljoin, urlparse from pygments import highlight from pygments.lexers import get_lexer_by_name diff --git a/tests/unit/engines/test_command.py b/tests/unit/engines/test_command.py index 0aa1c6201..8f88b617e 100644 --- a/tests/unit/engines/test_command.py +++ b/tests/unit/engines/test_command.py @@ -14,7 +14,6 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. ''' -from sys import version_info from searx.engines import command as command_engine from searx.testing import SearxTestCase diff --git a/tests/unit/test_webadapter.py b/tests/unit/test_webadapter.py index 7806353d3..f620cf300 100644 --- a/tests/unit/test_webadapter.py +++ b/tests/unit/test_webadapter.py @@ -5,7 +5,7 @@ from searx.preferences import Preferences from searx.engines import engines import searx.search -from searx.search import EngineRef, SearchQuery +from searx.search import EngineRef from searx.webadapter import validate_engineref_list