on master help sign in
Drop Python 2 (3/n): objects
commit78883777438fc07833d983c50d9b131eb6feb9eb authorDalf <alex@al-f.net> dateWed 12 Aug 2020, 09:42 (6 years ago) parent78df10f
8 files changed+16−16
searx/exceptions.py+1−1 searx/poolrequests.py+3−3 searx/preferences.py+2−2 searx/query.py+2−2 searx/results.py+2−2 searx/search.py+4−4 searx/webapp.py+1−1 tests/unit/test_preferences.py+1−1
searx/exceptions.py+1−1
@@ -27,7 +27,7 @@ class SearxParameterException(SearxException):
2727 message = 'Empty ' + name + ' parameter'
2828 else:
2929 message = 'Invalid value "' + value + '" for parameter ' + name
30− super(SearxParameterException, self).__init__(message)
30+ super().__init__(message)
3131 self.message = message
3232 self.parameter_name = name
3333 self.parameter_value = value
searx/poolrequests.py+3−3
@@ -20,7 +20,7 @@ class HTTPAdapterWithConnParams(requests.adapters.HTTPAdapter):
2020 self.config = {}
2121 self.proxy_manager = {}
2222
23− super(requests.adapters.HTTPAdapter, self).__init__()
23+ super().__init__()
2424
2525 self._pool_connections = pool_connections
2626 self._pool_maxsize = pool_maxsize
@@ -60,7 +60,7 @@ else:
6060class SessionSinglePool(requests.Session):
6161
6262 def __init__(self):
63− super(SessionSinglePool, self).__init__()
63+ super().__init__()
6464
6565 # reuse the same adapters
6666 with RLock():
@@ -71,7 +71,7 @@ class SessionSinglePool(requests.Session):
7171 def close(self):
7272 """Call super, but clear adapters since there are managed globaly"""
7373 self.adapters.clear()
74− super(SessionSinglePool, self).close()
74+ super().close()
7575
7676
7777def set_timeout_for_thread(timeout, start_time=None):
searx/preferences.py+2−2
@@ -32,7 +32,7 @@ class ValidationException(Exception):
3232 """
3333
3434
35−class Setting(object):
35+class Setting:
3636 """Base class of user settings"""
3737
3838 def __init__(self, default_value, **kwargs):
@@ -310,7 +310,7 @@ class PluginsSetting(SwitchableSetting):
310310 return [item[len('plugin_'):] for item in items]
311311
312312
313−class Preferences(object):
313+class Preferences:
314314 """Validates and saves preferences to cookies"""
315315
316316 def __init__(self, themes, categories, engines, plugins):
searx/query.py+2−2
@@ -28,7 +28,7 @@ from searx.engines import (
2828VALID_LANGUAGE_CODE = re.compile(r'^[a-z]{2,3}(-[a-zA-Z]{2})?$')
2929
3030
31−class RawTextQuery(object):
31+class RawTextQuery:
3232 """parse raw text query (the value from the html input)"""
3333
3434 def __init__(self, query, disabled_engines):
@@ -178,7 +178,7 @@ class RawTextQuery(object):
178178 return ''.join(self.query_parts)
179179
180180
181−class SearchQuery(object):
181+class SearchQuery:
182182 """container for all the search parameters (query, language, etc...)"""
183183
184184 def __init__(self, query, engines, categories, lang, safesearch, pageno, time_range,
searx/results.py+2−2
@@ -122,14 +122,14 @@ def result_score(result):
122122 return sum((occurences * weight) / position for position in result['positions'])
123123
124124
125−class ResultContainer(object):
125+class ResultContainer:
126126 """docstring for ResultContainer"""
127127
128128 __slots__ = '_merged_results', 'infoboxes', 'suggestions', 'answers', 'corrections', '_number_of_results',\
129129 '_ordered', 'paging', 'unresponsive_engines', 'timings', 'redirect_url'
130130
131131 def __init__(self):
132− super(ResultContainer, self).__init__()
132+ super().__init__()
133133 self._merged_results = []
134134 self.infoboxes = []
135135 self.suggestions = set()
searx/search.py+4−4
@@ -407,12 +407,12 @@ def get_search_query_from_webapp(preferences, form):
407407 raw_text_query)
408408
409409
410−class Search(object):
410+class Search:
411411 """Search information container"""
412412
413413 def __init__(self, search_query):
414414 # init vars
415− super(Search, self).__init__()
415+ super().__init__()
416416 self.search_query = search_query
417417 self.result_container = ResultContainer()
418418 self.actual_timeout = None
@@ -534,13 +534,13 @@ class SearchWithPlugins(Search):
534534 """Similar to the Search class but call the plugins."""
535535
536536 def __init__(self, search_query, ordered_plugin_list, request):
537− super(SearchWithPlugins, self).__init__(search_query)
537+ super().__init__(search_query)
538538 self.ordered_plugin_list = ordered_plugin_list
539539 self.request = request
540540
541541 def search(self):
542542 if plugins.call(self.ordered_plugin_list, 'pre_search', self.request, self):
543− super(SearchWithPlugins, self).search()
543+ super().search()
544544
545545 plugins.call(self.ordered_plugin_list, 'post_search', self.request, self)
546546
searx/webapp.py+1−1
@@ -1040,7 +1040,7 @@ def run():
10401040 )
10411041
10421042
1043−class ReverseProxyPathFix(object):
1043+class ReverseProxyPathFix:
10441044 '''Wrap the application in this middleware and configure the
10451045 front-end server to add these headers, to let you quietly bind
10461046 this to a URL other than / and to an HTTP scheme that is
tests/unit/test_preferences.py+1−1
@@ -3,7 +3,7 @@ from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentExc
33from searx.testing import SearxTestCase
44
55
6−class PluginStub(object):
6+class PluginStub:
77
88 def __init__(self, id, default_on):
99 self.id = id