mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 13:49:26 +02:00
[enh] py3 compatibility
This commit is contained in:
parent
46a2c63f8e
commit
52e615dede
115 changed files with 517 additions and 513 deletions
|
@ -1,8 +1,12 @@
|
|||
from sys import version_info
|
||||
from functools import reduce
|
||||
from operator import mul
|
||||
|
||||
from flask_babel import gettext
|
||||
|
||||
if version_info[0] == 3:
|
||||
unicode = str
|
||||
|
||||
keywords = ('min',
|
||||
'max',
|
||||
'avg',
|
||||
|
@ -19,22 +23,22 @@ def answer(query):
|
|||
return []
|
||||
|
||||
try:
|
||||
args = map(float, parts[1:])
|
||||
args = list(map(float, parts[1:]))
|
||||
except:
|
||||
return []
|
||||
|
||||
func = parts[0]
|
||||
answer = None
|
||||
|
||||
if func == 'min':
|
||||
if func == b'min':
|
||||
answer = min(args)
|
||||
elif func == 'max':
|
||||
elif func == b'max':
|
||||
answer = max(args)
|
||||
elif func == 'avg':
|
||||
elif func == b'avg':
|
||||
answer = sum(args) / len(args)
|
||||
elif func == 'sum':
|
||||
elif func == b'sum':
|
||||
answer = sum(args)
|
||||
elif func == 'prod':
|
||||
elif func == b'prod':
|
||||
answer = reduce(mul, args, 1)
|
||||
|
||||
if answer is None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue