From 1022228d950c2a809ed613df1a515d9a6cafda7c Mon Sep 17 00:00:00 2001 From: Dalf Date: Thu, 6 Aug 2020 17:42:46 +0200 Subject: Drop Python 2 (1/n): remove unicode string and url_utils --- searx/search.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'searx/search.py') diff --git a/searx/search.py b/searx/search.py index 79896e5e1..0af004603 100644 --- a/searx/search.py +++ b/searx/search.py @@ -20,8 +20,8 @@ import sys import threading from time import time from uuid import uuid4 +from _thread import start_new_thread -import six from flask_babel import gettext import requests.exceptions import searx.poolrequests as requests_lib @@ -37,13 +37,6 @@ from searx import logger from searx.plugins import plugins from searx.exceptions import SearxParameterException -try: - from thread import start_new_thread -except: - from _thread import start_new_thread - -if sys.version_info[0] == 3: - unicode = str logger = logger.getChild('search') @@ -355,11 +348,11 @@ def get_search_query_from_webapp(preferences, form): load_default_categories = True for pd_name, pd in form.items(): if pd_name == 'categories': - query_categories.extend(categ for categ in map(unicode.strip, pd.split(',')) if categ in categories) + query_categories.extend(categ for categ in map(str.strip, pd.split(',')) if categ in categories) elif pd_name == 'engines': pd_engines = [{'category': engines[engine].categories[0], 'name': engine} - for engine in map(unicode.strip, pd.split(',')) if engine in engines] + for engine in map(str.strip, pd.split(',')) if engine in engines] if pd_engines: query_engines.extend(pd_engines) load_default_categories = False @@ -434,7 +427,7 @@ class Search(object): # This means there was a valid bang and the # rest of the search does not need to be continued - if isinstance(self.result_container.redirect_url, six.string_types): + if isinstance(self.result_container.redirect_url, str): return self.result_container # start time start_time = time() -- cgit v1.2.3 From 78883777438fc07833d983c50d9b131eb6feb9eb Mon Sep 17 00:00:00 2001 From: Dalf Date: Wed, 12 Aug 2020 09:42:27 +0200 Subject: Drop Python 2 (3/n): objects --- searx/search.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'searx/search.py') diff --git a/searx/search.py b/searx/search.py index 0af004603..3695128ab 100644 --- a/searx/search.py +++ b/searx/search.py @@ -407,12 +407,12 @@ def get_search_query_from_webapp(preferences, form): raw_text_query) -class Search(object): +class Search: """Search information container""" def __init__(self, search_query): # init vars - super(Search, self).__init__() + super().__init__() self.search_query = search_query self.result_container = ResultContainer() self.actual_timeout = None @@ -534,13 +534,13 @@ class SearchWithPlugins(Search): """Similar to the Search class but call the plugins.""" def __init__(self, search_query, ordered_plugin_list, request): - super(SearchWithPlugins, self).__init__(search_query) + super().__init__(search_query) self.ordered_plugin_list = ordered_plugin_list self.request = request def search(self): if plugins.call(self.ordered_plugin_list, 'pre_search', self.request, self): - super(SearchWithPlugins, self).search() + super().search() plugins.call(self.ordered_plugin_list, 'post_search', self.request, self) -- cgit v1.2.3