Workaround xisbn sometimes returning incomplete isbn pools

This commit is contained in:
Kovid Goyal 2011-06-16 09:48:08 -06:00
parent 16ca0fa068
commit 5e914a5a20
2 changed files with 12 additions and 4 deletions

View File

@ -85,6 +85,10 @@ class ISBNMerge(object):
isbns, min_year = xisbn.get_isbn_pool(isbn)
if not isbns:
isbns = frozenset([isbn])
if isbns in self.pools:
# xISBN had a brain fart
pool = self.pools[isbn]
else:
self.pools[isbns] = pool = (min_year, [])
if not self.pool_has_result_from_same_source(pool, result):

View File

@ -45,6 +45,11 @@ class xISBN(object):
ans.append(rec)
return ans
def isbns_in_data(self, data):
for rec in data:
for i in rec.get('isbn', []):
yield i
def get_data(self, isbn):
isbn = self.purify(isbn)
with self.lock:
@ -57,8 +62,7 @@ class xISBN(object):
data = []
id_ = len(self._data)
self._data.append(data)
for rec in data:
for i in rec.get('isbn', []):
for i in self.isbns_in_data(data):
self._map[i] = id_
self._map[isbn] = id_
return self._data[self._map[isbn]]