mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-03-16 22:20:31 +00:00
Applied 2to3 to convert all code to Python 3.X.
- Related to #128, but doesn't fix it since there are no tests for Python 3.X - It passes all tests in Python2.7
This commit is contained in:
parent
1ecf687d56
commit
34a172199c
3 changed files with 20 additions and 20 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from haystack import indexes
|
||||
|
||||
import models
|
||||
from . import models
|
||||
|
||||
|
||||
class DocumentIndex(indexes.SearchIndex):
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ from core.tests.mocks import MockSearchResult
|
|||
|
||||
def get_terms(backend, *args):
|
||||
result = subprocess.check_output(['delve'] + list(args) + [backend.path], env=os.environ.copy())
|
||||
result = result.split(": ")[1].strip()
|
||||
return result.split(" ")
|
||||
result = result.split(b": ")[1].strip()
|
||||
return result.split(b" ")
|
||||
|
||||
|
||||
def pks(results):
|
||||
|
|
@ -78,7 +78,7 @@ class XapianMockSearchIndex(indexes.SearchIndex):
|
|||
return XapianMockModel
|
||||
|
||||
def prepare_sites(self, obj):
|
||||
return ['%d' % (i * obj.id) for i in xrange(1, 4)]
|
||||
return ['%d' % (i * obj.id) for i in range(1, 4)]
|
||||
|
||||
def prepare_tags(self, obj):
|
||||
if obj.id == 1:
|
||||
|
|
@ -89,7 +89,7 @@ class XapianMockSearchIndex(indexes.SearchIndex):
|
|||
return ['an', 'to', 'or']
|
||||
|
||||
def prepare_keys(self, obj):
|
||||
return [i * obj.id for i in xrange(1, 4)]
|
||||
return [i * obj.id for i in range(1, 4)]
|
||||
|
||||
def prepare_titles(self, obj):
|
||||
if obj.id == 1:
|
||||
|
|
@ -210,7 +210,7 @@ class XapianSearchBackendTestCase(HaystackBackendTestCase, TestCase):
|
|||
|
||||
self.sample_objs = []
|
||||
|
||||
for i in xrange(1, 4):
|
||||
for i in range(1, 4):
|
||||
mock = XapianMockModel()
|
||||
mock.id = i
|
||||
mock.author = 'david%s' % i
|
||||
|
|
@ -329,7 +329,7 @@ class XapianSearchBackendTestCase(HaystackBackendTestCase, TestCase):
|
|||
('2008-10-26T00:00:00', 0),
|
||||
])
|
||||
|
||||
facets = {'pub_date': {'start_date': datetime.datetime(2009, 02, 01),
|
||||
facets = {'pub_date': {'start_date': datetime.datetime(2009, 2, 1),
|
||||
'end_date': datetime.datetime(2009, 3, 15),
|
||||
'gap_by': 'day',
|
||||
'gap_amount': 15}}
|
||||
|
|
@ -502,9 +502,9 @@ class XapianSearchBackendTestCase(HaystackBackendTestCase, TestCase):
|
|||
self.assertEqual(str(self.backend.parse_query('value:0..10')),
|
||||
'Xapian::Query(VALUE_RANGE 16 000000000000 000000000010)')
|
||||
self.assertEqual(str(self.backend.parse_query('value:..10')),
|
||||
'Xapian::Query(VALUE_RANGE 16 %012d 000000000010)' % (-sys.maxint - 1))
|
||||
'Xapian::Query(VALUE_RANGE 16 %012d 000000000010)' % (-sys.maxsize - 1))
|
||||
self.assertEqual(str(self.backend.parse_query('value:10..*')),
|
||||
'Xapian::Query(VALUE_RANGE 16 000000000010 %012d)' % sys.maxint)
|
||||
'Xapian::Query(VALUE_RANGE 16 000000000010 %012d)' % sys.maxsize)
|
||||
self.assertEqual(str(self.backend.parse_query('popularity:25.5..100.0')),
|
||||
b'Xapian::Query(VALUE_RANGE 9 \xb2` \xba@)')
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ class XapianSearchBackendTestCase(HaystackBackendTestCase, TestCase):
|
|||
10 entries was not correct at some point.
|
||||
"""
|
||||
self.sample_objs = []
|
||||
number_list = range(1, 101)
|
||||
number_list = list(range(1, 101))
|
||||
for i in number_list:
|
||||
mock = XapianMockModel()
|
||||
mock.id = i
|
||||
|
|
@ -713,7 +713,7 @@ class XapianBoostBackendTestCase(HaystackBackendTestCase, TestCase):
|
|||
super(XapianBoostBackendTestCase, self).setUp()
|
||||
|
||||
self.sample_objs = []
|
||||
for i in xrange(1, 5):
|
||||
for i in range(1, 5):
|
||||
mock = AFourthMockModel()
|
||||
mock.id = i
|
||||
if i % 2:
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class XHValueRangeProcessor(xapian.ValueRangeProcessor):
|
|||
if field_type == 'text':
|
||||
begin = 'a' # TODO: A better way of getting a min text value?
|
||||
elif field_type == 'integer':
|
||||
begin = -sys.maxint - 1
|
||||
begin = -sys.maxsize - 1
|
||||
elif field_type == 'float':
|
||||
begin = float('-inf')
|
||||
elif field_type == 'date' or field_type == 'datetime':
|
||||
|
|
@ -104,7 +104,7 @@ class XHValueRangeProcessor(xapian.ValueRangeProcessor):
|
|||
if field_type == 'text':
|
||||
end = 'z' * 100 # TODO: A better way of getting a max text value?
|
||||
elif field_type == 'integer':
|
||||
end = sys.maxint
|
||||
end = sys.maxsize
|
||||
elif field_type == 'float':
|
||||
end = float('inf')
|
||||
elif field_type == 'date' or field_type == 'datetime':
|
||||
|
|
@ -263,7 +263,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
weights = index.get_field_weights()
|
||||
for field in self.schema:
|
||||
# not supported fields are ignored.
|
||||
if field['field_name'] not in data.keys():
|
||||
if field['field_name'] not in list(data.keys()):
|
||||
continue
|
||||
|
||||
if field['field_name'] in weights:
|
||||
|
|
@ -702,7 +702,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
|
||||
column = len(schema_fields)
|
||||
|
||||
for field_name, field_class in sorted(fields.items(), key=lambda n: n[0]):
|
||||
for field_name, field_class in sorted(list(fields.items()), key=lambda n: n[0]):
|
||||
if field_class.document is True:
|
||||
content_field_name = field_class.index_fieldname
|
||||
|
||||
|
|
@ -780,7 +780,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
field_name, field_type = field['field_name'], field['type']
|
||||
|
||||
facet_dict[field_name] = []
|
||||
for facet in spy.values():
|
||||
for facet in list(spy.values()):
|
||||
facet_dict[field_name].append((_from_xapian_value(facet.term, field_type),
|
||||
facet.termfreq))
|
||||
return facet_dict
|
||||
|
|
@ -805,7 +805,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
for item in field_value: # Facet each item in a MultiValueField
|
||||
facet_list[item] = facet_list.get(item, 0) + 1
|
||||
|
||||
facet_dict[field] = facet_list.items()
|
||||
facet_dict[field] = list(facet_list.items())
|
||||
return facet_dict
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -839,7 +839,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
"""
|
||||
facet_dict = {}
|
||||
|
||||
for date_facet, facet_params in date_facets.iteritems():
|
||||
for date_facet, facet_params in list(date_facets.items()):
|
||||
gap_type = facet_params.get('gap_by')
|
||||
gap_value = facet_params.get('gap_amount', 1)
|
||||
date_range = facet_params['start_date']
|
||||
|
|
@ -905,7 +905,7 @@ class XapianSearchBackend(BaseSearchBackend):
|
|||
eg. {'name': ('a*', 5)}
|
||||
"""
|
||||
facet_dict = {}
|
||||
for field, query in dict(query_facets).items():
|
||||
for field, query in list(dict(query_facets).items()):
|
||||
facet_dict[field] = (query, self.search(self.parse_query(query))['hits'])
|
||||
|
||||
return facet_dict
|
||||
|
|
@ -1064,7 +1064,7 @@ class XapianSearchQuery(BaseSearchQuery):
|
|||
xapian.Query(
|
||||
xapian.Query.OP_SCALE_WEIGHT,
|
||||
self._term_query(term, None, None), value
|
||||
) for term, value in self.boost.iteritems()
|
||||
) for term, value in list(self.boost.items())
|
||||
]
|
||||
query = xapian.Query(
|
||||
xapian.Query.OP_AND_MAYBE, query,
|
||||
|
|
|
|||
Loading…
Reference in a new issue