summaryrefslogtreecommitdiff
path: root/searx/answerers
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2020-08-11 16:25:03 +0200
committerAlexandre Flament <alex@al-f.net>2020-09-10 10:49:42 +0200
commitc225db45c8a4ab466bff049216f7e0189dc1b067 (patch)
tree16be3299a6faf15538fc1f2cf181aadc422039fd /searx/answerers
parent78883777438fc07833d983c50d9b131eb6feb9eb (diff)
downloadsearxng-c225db45c8a4ab466bff049216f7e0189dc1b067.tar.gz
searxng-c225db45c8a4ab466bff049216f7e0189dc1b067.zip
Drop Python 2 (4/n): SearchQuery.query is a str instead of bytes
Diffstat (limited to 'searx/answerers')
-rw-r--r--searx/answerers/__init__.py4
-rw-r--r--searx/answerers/random/answerer.py12
-rw-r--r--searx/answerers/statistics/answerer.py10
3 files changed, 13 insertions, 13 deletions
diff --git a/searx/answerers/__init__.py b/searx/answerers/__init__.py
index 47cc33ed3..97e7e5854 100644
--- a/searx/answerers/__init__.py
+++ b/searx/answerers/__init__.py
@@ -32,10 +32,10 @@ def ask(query):
results = []
query_parts = list(filter(None, query.query.split()))
- if query_parts[0].decode() not in answerers_by_keywords:
+ if query_parts[0] not in answerers_by_keywords:
return results
- for answerer in answerers_by_keywords[query_parts[0].decode()]:
+ for answerer in answerers_by_keywords[query_parts[0]]:
result = answerer(query)
if result:
results.append(result)
diff --git a/searx/answerers/random/answerer.py b/searx/answerers/random/answerer.py
index aaf9e1cf6..d5223e517 100644
--- a/searx/answerers/random/answerer.py
+++ b/searx/answerers/random/answerer.py
@@ -39,11 +39,11 @@ def random_uuid():
return str(uuid.uuid4())
-random_types = {b'string': random_string,
- b'int': random_int,
- b'float': random_float,
- b'sha256': random_sha256,
- b'uuid': random_uuid}
+random_types = {'string': random_string,
+ 'int': random_int,
+ 'float': random_float,
+ 'sha256': random_sha256,
+ 'uuid': random_uuid}
# required answerer function
@@ -64,4 +64,4 @@ def answer(query):
def self_info():
return {'name': gettext('Random value generator'),
'description': gettext('Generate different random values'),
- 'examples': ['random {}'.format(x.decode()) for x in random_types]}
+ 'examples': ['random {}'.format(x) for x in random_types]}
diff --git a/searx/answerers/statistics/answerer.py b/searx/answerers/statistics/answerer.py
index cfd1b3e23..abd4be7f5 100644
--- a/searx/answerers/statistics/answerer.py
+++ b/searx/answerers/statistics/answerer.py
@@ -27,15 +27,15 @@ def answer(query):
func = parts[0]
answer = None
- if func == b'min':
+ if func == 'min':
answer = min(args)
- elif func == b'max':
+ elif func == 'max':
answer = max(args)
- elif func == b'avg':
+ elif func == 'avg':
answer = sum(args) / len(args)
- elif func == b'sum':
+ elif func == 'sum':
answer = sum(args)
- elif func == b'prod':
+ elif func == 'prod':
answer = reduce(mul, args, 1)
if answer is None: