isbndb.py minor changes

This commit is contained in:
Sengian 2010-10-11 00:35:07 +02:00
parent 5e1888210a
commit 9590ba6234

View File

@ -74,14 +74,14 @@ class ISBNDBMetadata(Metadata):
if authors: if authors:
self.authors = authors self.authors = authors
try: try:
self.author_sort = self.tostring(book.find('authors').find('person')) self.author_sort = tostring(book.find('authors').find('person'))
if self.authors and self.author_sort == self.authors[0]: if self.authors and self.author_sort == self.authors[0]:
self.author_sort = None self.author_sort = None
except: except:
pass pass
self.publisher = self.tostring(book.find('publishertext')) self.publisher = tostring(book.find('publishertext'))
summ = self.tostring(book.find('summary')) summ = tostring(book.find('summary'))
if summ: if summ:
self.comments = 'SUMMARY:\n'+summ self.comments = 'SUMMARY:\n'+summ
@ -141,7 +141,7 @@ def create_books(opts, args, timeout=5.):
print ('ISBNDB query: '+url) print ('ISBNDB query: '+url)
tans = [ISBNDBMetadata(book) for book in fetch_metadata(url, timeout=timeout)] tans = [ISBNDBMetadata(book) for book in fetch_metadata(url, timeout=timeout)]
ans = [] '''ans = []
for x in tans: for x in tans:
add = True add = True
for y in ans: for y in ans:
@ -149,7 +149,9 @@ def create_books(opts, args, timeout=5.):
add = False add = False
if add: if add:
ans.append(x) ans.append(x)
return ans return ans'''
#remove duplicates ISBN
return dict((book.isbn, book) for book in tans).values()
def main(args=sys.argv): def main(args=sys.argv):
parser = option_parser() parser = option_parser()