Commit dd2e7816 authored by Michal Čihař's avatar Michal Čihař

Use unctools.reduce for Python 3 compatibility

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4829e3d3
......@@ -18,10 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import functools
import traceback
import multiprocessing
# pylint: disable=W0622
from functools import reduce
from django.db import models
from django.db.models import Q
......@@ -235,7 +234,7 @@ class UnitManager(models.Manager):
if params[param]:
queries.append(param)
query = reduce(
query = functools.reduce(
lambda q, value:
q | Q(**{'%s%s' % (value, modifier): params['q']}),
queries,
......
......@@ -22,6 +22,7 @@
Whoosh based full text search.
'''
import functools
import shutil
from whoosh.fields import SchemaClass, TEXT, NUMERIC
from whoosh.filedb.filestore import FileStorage
......@@ -250,7 +251,7 @@ def base_search(index, query, params, search, schema):
queries.append(
parser.parse(query)
)
terms = reduce(lambda x, y: x | y, queries)
terms = functools.reduce(lambda x, y: x | y, queries)
return [result['pk'] for result in searcher.search(terms)]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment