import picture.models
from pdcounter.models import Author as PDCounterAuthor, BookStub as PDCounterBook
from itertools import chain
-import sunburnt
-import custom
+import scorched
+from . import custom
import operator
import logging
from wolnelektury.utils import makedirs
"""
uids = set()
for q in queries:
- if isinstance(q, sunburnt.search.LuceneQuery):
+ if isinstance(q, scorched.search.LuceneQuery):
q = self.index.query(q)
q.field_limiter.update(['uid'])
st = 0
elif type_indicator == dcparser.as_person:
p = getattr(book_info, field.name)
if isinstance(p, dcparser.Person):
- persons = unicode(p)
+ persons = str(p)
else:
- persons = ', '.join(map(unicode, p))
+ persons = ', '.join(map(str, p))
fields[field.name] = persons
elif type_indicator == dcparser.as_date:
dt = getattr(book_info, field.name)
fid = start.attrib['id'][1:]
handle_text.append(lambda text: None)
if start.text is not None:
- fragments[fid]['themes'] += map(unicode.strip, map(unicode, (start.text.split(','))))
+ fragments[fid]['themes'] += map(str.strip, map(str, (start.text.split(','))))
elif end is not None and end.tag == 'motyw':
handle_text.pop()
result._book = book
return result
- def __unicode__(self):
+ def __str__(self):
return u"<SR id=%d %d(%d) hits score=%f %d snippets>" % \
(self.book_id, len(self._hits),
len(self._processed_hits) if self._processed_hits else -1,
self._score, len(self.snippets))
- def __str__(self):
- return unicode(self).encode('utf-8')
+ def __bytes__(self):
+ return str(self).encode('utf-8')
@property
def score(self):
if self.query_terms is not None:
for i in range(0, len(f[self.OTHER]['themes'])):
tms = f[self.OTHER]['themes'][i].split(r' +') + f[self.OTHER]['themes_pl'][i].split(' ')
- tms = map(unicode.lower, tms)
+ tms = map(str.lower, tms)
for qt in self.query_terms:
if qt in tms:
themes_hit.add(f[self.OTHER]['themes'][i])
self._hits.append(hit)
- def __unicode__(self):
+ def __str__(self):
return u"<PR id=%d score=%f >" % (self.picture_id, self._score)
def __repr__(self):
- return unicode(self)
+ return str(self)
@property
def score(self):
if self.query_terms is not None:
for i in range(0, len(hit[self.OTHER]['themes'])):
tms = hit[self.OTHER]['themes'][i].split(r' +') + hit[self.OTHER]['themes_pl'][i].split(' ')
- tms = map(unicode.lower, tms)
+ tms = map(str.lower, tms)
for qt in self.query_terms:
if qt in tms:
themes_hit.add(hit[self.OTHER]['themes'][i])
num -= 1
idx += 1
- except IOError, e:
+ except IOError as e:
book = catalogue.models.Book.objects.filter(id=book_id)
if not book:
log.error("Book does not exist for book id = %d" % book_id)