diff options
| author | Alexandre Flament <alex@al-f.net> | 2020-12-01 15:31:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-01 15:31:10 +0100 |
| commit | 219af243a20899d0c8a677700c36e339d7cdcc74 (patch) | |
| tree | b7b98f65cf6cc8127f1d6a06e37419fe45222871 /searx/engines | |
| parent | a1e6bc4cee2690eb7f2103901ada9a50846a7419 (diff) | |
| parent | 8aa2a7556ad80d3d644287fc17832050f3a5a303 (diff) | |
Merge pull request #2318 from dalf/add-pylint
Add pylint
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/__init__.py | 4 | ||||
| -rw-r--r-- | searx/engines/acgsou.py | 1 | ||||
| -rw-r--r-- | searx/engines/arxiv.py | 2 | ||||
| -rwxr-xr-x | searx/engines/base.py | 5 | ||||
| -rw-r--r-- | searx/engines/bing_images.py | 2 | ||||
| -rw-r--r-- | searx/engines/bing_news.py | 2 | ||||
| -rw-r--r-- | searx/engines/bing_videos.py | 2 | ||||
| -rw-r--r-- | searx/engines/currency_convert.py | 2 | ||||
| -rw-r--r-- | searx/engines/duckduckgo.py | 4 | ||||
| -rw-r--r-- | searx/engines/duckduckgo_definitions.py | 2 | ||||
| -rw-r--r-- | searx/engines/duckduckgo_images.py | 2 | ||||
| -rw-r--r-- | searx/engines/filecrop.py | 2 | ||||
| -rw-r--r-- | searx/engines/google_images.py | 5 | ||||
| -rw-r--r-- | searx/engines/google_news.py | 2 | ||||
| -rw-r--r-- | searx/engines/peertube.py | 1 | ||||
| -rw-r--r-- | searx/engines/pubmed.py | 2 | ||||
| -rw-r--r-- | searx/engines/wikidata.py | 13 | ||||
| -rw-r--r-- | searx/engines/yahoo_news.py | 2 |
18 files changed, 26 insertions, 29 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index a80afb1c6..a78c4a8c3 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -72,7 +72,7 @@ def load_engine(engine_data): try: engine = load_module(engine_module + '.py', engine_dir) - except (SyntaxError, KeyboardInterrupt, SystemExit, SystemError, ImportError, RuntimeError) as e: + except (SyntaxError, KeyboardInterrupt, SystemExit, SystemError, ImportError, RuntimeError): logger.exception('Fatal exception in engine "{}"'.format(engine_module)) sys.exit(1) except: @@ -234,7 +234,7 @@ def get_engines_stats(preferences): results = to_percentage(results, max_results) scores = to_percentage(scores, max_score) scores_per_result = to_percentage(scores_per_result, max_score_per_result) - erros = to_percentage(errors, max_errors) + errors = to_percentage(errors, max_errors) return [ ( diff --git a/searx/engines/acgsou.py b/searx/engines/acgsou.py index 553b49b69..a436df283 100644 --- a/searx/engines/acgsou.py +++ b/searx/engines/acgsou.py @@ -41,7 +41,6 @@ def response(resp): # defaults filesize = 0 magnet_link = "magnet:?xt=urn:btih:{}&tr=http://tracker.acgsou.com:2710/announce" - torrent_link = "" try: category = extract_text(result.xpath(xpath_category)[0]) diff --git a/searx/engines/arxiv.py b/searx/engines/arxiv.py index e54de4a58..6e231c382 100644 --- a/searx/engines/arxiv.py +++ b/searx/engines/arxiv.py @@ -61,7 +61,7 @@ def response(resp): content = content_string.format(doi_content="", abstract_content=abstract) if len(content) > 300: - content = content[0:300] + "..." + content = content[0:300] + "..." # TODO: center snippet on query term publishedDate = datetime.strptime(entry.xpath('.//published')[0].text, '%Y-%m-%dT%H:%M:%SZ') diff --git a/searx/engines/base.py b/searx/engines/base.py index 0114f9798..3648d7ed0 100755 --- a/searx/engines/base.py +++ b/searx/engines/base.py @@ -80,10 +80,7 @@ def response(resp): date = datetime.now() # needed in case no dcdate is available for an item for item in entry: - if item.attrib["name"] == "dchdate": - harvestDate = item.text - - elif item.attrib["name"] == "dcdate": + if item.attrib["name"] == "dcdate": date = item.text elif item.attrib["name"] == "dctitle": diff --git a/searx/engines/bing_images.py b/searx/engines/bing_images.py index 3085e1deb..2bcf82b84 100644 --- a/searx/engines/bing_images.py +++ b/searx/engines/bing_images.py @@ -18,7 +18,7 @@ from json import loads from searx.utils import match_language from searx.engines.bing import language_aliases -from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import # engine dependent config categories = ['images'] diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py index aeef7d19a..5489c7549 100644 --- a/searx/engines/bing_news.py +++ b/searx/engines/bing_news.py @@ -17,7 +17,7 @@ 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 language_aliases -from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import # engine dependent config categories = ['news'] diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py index 4393ea590..143c71a3e 100644 --- a/searx/engines/bing_videos.py +++ b/searx/engines/bing_videos.py @@ -16,7 +16,7 @@ from urllib.parse import urlencode from searx.utils import match_language from searx.engines.bing import language_aliases -from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.bing import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import categories = ['videos'] paging = True diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py index 0e91d31e9..f41c135b9 100644 --- a/searx/engines/currency_convert.py +++ b/searx/engines/currency_convert.py @@ -41,8 +41,6 @@ def request(query, params): from_currency = name_to_iso4217(from_currency.strip()) to_currency = name_to_iso4217(to_currency.strip()) - q = (from_currency + to_currency).upper() - params['url'] = url.format(from_currency, to_currency) params['amount'] = amount params['from'] = from_currency diff --git a/searx/engines/duckduckgo.py b/searx/engines/duckduckgo.py index 21cd926aa..c1c984623 100644 --- a/searx/engines/duckduckgo.py +++ b/searx/engines/duckduckgo.py @@ -49,11 +49,11 @@ correction_xpath = '//div[@id="did_you_mean"]//a' # match query's language to a region code that duckduckgo will accept -def get_region_code(lang, lang_list=[]): +def get_region_code(lang, lang_list=None): if lang == 'all': return None - lang_code = match_language(lang, lang_list, language_aliases, 'wt-WT') + lang_code = match_language(lang, lang_list or [], language_aliases, 'wt-WT') lang_parts = lang_code.split('-') # country code goes first diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py index 5758022d2..5a7649173 100644 --- a/searx/engines/duckduckgo_definitions.py +++ b/searx/engines/duckduckgo_definitions.py @@ -16,7 +16,7 @@ from lxml import html from searx import logger from searx.data import WIKIDATA_UNITS from searx.engines.duckduckgo import language_aliases -from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import 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 diff --git a/searx/engines/duckduckgo_images.py b/searx/engines/duckduckgo_images.py index 943b74880..438a8d54c 100644 --- a/searx/engines/duckduckgo_images.py +++ b/searx/engines/duckduckgo_images.py @@ -16,7 +16,7 @@ from json import loads from urllib.parse import urlencode from searx.engines.duckduckgo import get_region_code -from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.duckduckgo import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import from searx.poolrequests import get # engine dependent config diff --git a/searx/engines/filecrop.py b/searx/engines/filecrop.py index eef5be6e8..0331e7b19 100644 --- a/searx/engines/filecrop.py +++ b/searx/engines/filecrop.py @@ -8,7 +8,7 @@ search_url = url + '/search.php?{query}&size_i=0&size_f=100000000&engine_r=1&eng paging = True -class FilecropResultParser(HTMLParser): +class FilecropResultParser(HTMLParser): # pylint: disable=W0223 # (see https://bugs.python.org/issue31844) def __init__(self): HTMLParser.__init__(self) diff --git a/searx/engines/google_images.py b/searx/engines/google_images.py index 9669d81c3..a3daf6070 100644 --- a/searx/engines/google_images.py +++ b/searx/engines/google_images.py @@ -29,10 +29,7 @@ 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 -# pylint: enable=unused-import +from searx.engines.google import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import from searx.engines.google import ( get_lang_country, diff --git a/searx/engines/google_news.py b/searx/engines/google_news.py index 6cfc0c8e7..f1b7cfa79 100644 --- a/searx/engines/google_news.py +++ b/searx/engines/google_news.py @@ -13,7 +13,7 @@ from urllib.parse import urlencode from lxml import html from searx.utils import match_language -from searx.engines.google import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.google import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import # search-url categories = ['news'] diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py index 58ff38c02..e43b2a6b7 100644 --- a/searx/engines/peertube.py +++ b/searx/engines/peertube.py @@ -90,6 +90,5 @@ def response(resp): def _fetch_supported_languages(resp): - ret_val = {} peertube_languages = list(loads(resp.text).keys()) return peertube_languages diff --git a/searx/engines/pubmed.py b/searx/engines/pubmed.py index 7eb2e92f9..07c45709e 100644 --- a/searx/engines/pubmed.py +++ b/searx/engines/pubmed.py @@ -81,7 +81,7 @@ def response(resp): pass if len(content) > 300: - content = content[0:300] + "..." + content = content[0:300] + "..." # TODO: center snippet on query term res_dict = {'url': url, diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index 3d8daca5d..539ce5ad4 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -23,7 +23,7 @@ from searx.data import WIKIDATA_UNITS from searx.poolrequests import post, get 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 +from searx.engines.wikipedia import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import logger = logger.getChild('wikidata') @@ -228,7 +228,7 @@ def get_results(attribute_result, attributes, language): # Should use normalized value p:P2046/psn:P2046/wikibase:quantityAmount area = attribute_result.get('P2046') osm_zoom = area_to_osm_zoom(area) if area else 19 - url = attribute.get_str(attribute_result, language, osm_zoom=osm_zoom) + url = attribute.get_geo_url(attribute_result, osm_zoom=osm_zoom) if url: infobox_urls.append({'title': attribute.get_label(language), 'url': url, @@ -546,7 +546,14 @@ class WDGeoAttribute(WDAttribute): def get_group_by(self): return self.get_select() - def get_str(self, result, language, osm_zoom=19): + def get_str(self, result, language): + latitude = result.get(self.name + 'Lat') + longitude = result.get(self.name + 'Long') + if latitude and longitude: + return latitude + ' ' + longitude + return None + + def get_geo_url(self, result, osm_zoom=19): latitude = result.get(self.name + 'Lat') longitude = result.get(self.name + 'Long') if latitude and longitude: diff --git a/searx/engines/yahoo_news.py b/searx/engines/yahoo_news.py index 11941cfe1..793d1104a 100644 --- a/searx/engines/yahoo_news.py +++ b/searx/engines/yahoo_news.py @@ -14,7 +14,7 @@ from datetime import datetime, timedelta from urllib.parse import urlencode from lxml import html from searx.engines.yahoo import parse_url, language_aliases -from searx.engines.yahoo import _fetch_supported_languages, supported_languages_url # NOQA +from searx.engines.yahoo import _fetch_supported_languages, supported_languages_url # NOQA # pylint: disable=unused-import from dateutil import parser from searx.utils import extract_text, extract_url, match_language |