summaryrefslogtreecommitdiff
path: root/searx/search.py
diff options
context:
space:
mode:
authorNoémi Ványi <kvch@users.noreply.github.com>2020-09-12 14:51:35 +0200
committerGitHub <noreply@github.com>2020-09-12 14:51:35 +0200
commit2370234d0978f59dd62efa4a4931e41ad31444d1 (patch)
treed3863e22b3d34092484146ce0bdc6e0ca8d36216 /searx/search.py
parent272158944bf13503e2597018fc60a00baddec660 (diff)
parentbdac99d4f0349a71d7ecb9a4c61687356afedd6b (diff)
Merge pull request #2137 from dalf/drop-python-2
Drop Python 2
Diffstat (limited to 'searx/search.py')
-rw-r--r--searx/search.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/searx/search.py b/searx/search.py
index 79896e5e1..3695128ab 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
@@ -414,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
@@ -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()
@@ -541,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)