mirror of
https://github.com/searxng/searxng.git
synced 2024-11-16 17:40:11 +01:00
Drop Python 2 (3/n): objects
This commit is contained in:
parent
78df10fb55
commit
7888377743
@ -27,7 +27,7 @@ class SearxParameterException(SearxException):
|
|||||||
message = 'Empty ' + name + ' parameter'
|
message = 'Empty ' + name + ' parameter'
|
||||||
else:
|
else:
|
||||||
message = 'Invalid value "' + value + '" for parameter ' + name
|
message = 'Invalid value "' + value + '" for parameter ' + name
|
||||||
super(SearxParameterException, self).__init__(message)
|
super().__init__(message)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.parameter_name = name
|
self.parameter_name = name
|
||||||
self.parameter_value = value
|
self.parameter_value = value
|
||||||
|
@ -20,7 +20,7 @@ class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter):
|
|||||||
self.config = {}
|
self.config = {}
|
||||||
self.proxy_manager = {}
|
self.proxy_manager = {}
|
||||||
|
|
||||||
super(requests.adapters.HTTPAdapter, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
self._pool_connections = pool_connections
|
self._pool_connections = pool_connections
|
||||||
self._pool_maxsize = pool_maxsize
|
self._pool_maxsize = pool_maxsize
|
||||||
@ -60,7 +60,7 @@ else:
|
|||||||
class SessionSinglePool(requests.Session):
|
class SessionSinglePool(requests.Session):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(SessionSinglePool, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
# reuse the same adapters
|
# reuse the same adapters
|
||||||
with RLock():
|
with RLock():
|
||||||
@ -71,7 +71,7 @@ class SessionSinglePool(requests.Session):
|
|||||||
def close(self):
|
def close(self):
|
||||||
"""Call super, but clear adapters since there are managed globaly"""
|
"""Call super, but clear adapters since there are managed globaly"""
|
||||||
self.adapters.clear()
|
self.adapters.clear()
|
||||||
super(SessionSinglePool, self).close()
|
super().close()
|
||||||
|
|
||||||
|
|
||||||
def set_timeout_for_thread(timeout, start_time=None):
|
def set_timeout_for_thread(timeout, start_time=None):
|
||||||
|
@ -32,7 +32,7 @@ class ValidationException(Exception):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Setting(object):
|
class Setting:
|
||||||
"""Base class of user settings"""
|
"""Base class of user settings"""
|
||||||
|
|
||||||
def __init__(self, default_value, **kwargs):
|
def __init__(self, default_value, **kwargs):
|
||||||
@ -310,7 +310,7 @@ class PluginsSetting(SwitchableSetting):
|
|||||||
return [item[len('plugin_'):] for item in items]
|
return [item[len('plugin_'):] for item in items]
|
||||||
|
|
||||||
|
|
||||||
class Preferences(object):
|
class Preferences:
|
||||||
"""Validates and saves preferences to cookies"""
|
"""Validates and saves preferences to cookies"""
|
||||||
|
|
||||||
def __init__(self, themes, categories, engines, plugins):
|
def __init__(self, themes, categories, engines, plugins):
|
||||||
|
@ -28,7 +28,7 @@ from searx.engines import (
|
|||||||
VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
|
VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
|
||||||
|
|
||||||
|
|
||||||
class RawTextQuery(object):
|
class RawTextQuery:
|
||||||
"""parse raw text query (the value from the html input)"""
|
"""parse raw text query (the value from the html input)"""
|
||||||
|
|
||||||
def __init__(self, query, disabled_engines):
|
def __init__(self, query, disabled_engines):
|
||||||
@ -178,7 +178,7 @@ class RawTextQuery(object):
|
|||||||
return ''.join(self.query_parts)
|
return ''.join(self.query_parts)
|
||||||
|
|
||||||
|
|
||||||
class SearchQuery(object):
|
class SearchQuery:
|
||||||
"""container for all the search parameters (query, language, etc...)"""
|
"""container for all the search parameters (query, language, etc...)"""
|
||||||
|
|
||||||
def __init__(self, query, engines, categories, lang, safesearch, pageno, time_range,
|
def __init__(self, query, engines, categories, lang, safesearch, pageno, time_range,
|
||||||
|
@ -122,14 +122,14 @@ def result_score(result):
|
|||||||
return sum((occurences * weight) / position for position in result['positions'])
|
return sum((occurences * weight) / position for position in result['positions'])
|
||||||
|
|
||||||
|
|
||||||
class ResultContainer(object):
|
class ResultContainer:
|
||||||
"""docstring for ResultContainer"""
|
"""docstring for ResultContainer"""
|
||||||
|
|
||||||
__slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
|
__slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
|
||||||
'_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url'
|
'_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(ResultContainer, self).__init__()
|
super().__init__()
|
||||||
self._merged_results = []
|
self._merged_results = []
|
||||||
self.infoboxes = []
|
self.infoboxes = []
|
||||||
self.suggestions = set()
|
self.suggestions = set()
|
||||||
|
@ -407,12 +407,12 @@ def get_search_query_from_webapp(preferences, form):
|
|||||||
raw_text_query)
|
raw_text_query)
|
||||||
|
|
||||||
|
|
||||||
class Search(object):
|
class Search:
|
||||||
"""Search information container"""
|
"""Search information container"""
|
||||||
|
|
||||||
def __init__(self, search_query):
|
def __init__(self, search_query):
|
||||||
# init vars
|
# init vars
|
||||||
super(Search, self).__init__()
|
super().__init__()
|
||||||
self.search_query = search_query
|
self.search_query = search_query
|
||||||
self.result_container = ResultContainer()
|
self.result_container = ResultContainer()
|
||||||
self.actual_timeout = None
|
self.actual_timeout = None
|
||||||
@ -534,13 +534,13 @@ class SearchWithPlugins(Search):
|
|||||||
"""Similar to the Search class but call the plugins."""
|
"""Similar to the Search class but call the plugins."""
|
||||||
|
|
||||||
def __init__(self, search_query, ordered_plugin_list, request):
|
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.ordered_plugin_list = ordered_plugin_list
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
if plugins.call(self.ordered_plugin_list, 'pre_search', self.request, 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)
|
plugins.call(self.ordered_plugin_list, 'post_search', self.request, self)
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ def run():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ReverseProxyPathFix(object):
|
class ReverseProxyPathFix:
|
||||||
'''Wrap the application in this middleware and configure the
|
'''Wrap the application in this middleware and configure the
|
||||||
front-end server to add these headers, to let you quietly bind
|
front-end server to add these headers, to let you quietly bind
|
||||||
this to a URL other than / and to an HTTP scheme that is
|
this to a URL other than / and to an HTTP scheme that is
|
||||||
|
@ -3,7 +3,7 @@ from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentExc
|
|||||||
from searx.testing import SearxTestCase
|
from searx.testing import SearxTestCase
|
||||||
|
|
||||||
|
|
||||||
class PluginStub(object):
|
class PluginStub:
|
||||||
|
|
||||||
def __init__(self, id, default_on):
|
def __init__(self, id, default_on):
|
||||||
self.id = id
|
self.id = id
|
||||||
|
Loading…
Reference in New Issue
Block a user