Minor fix to isbndb.py

This commit is contained in:
Sengian 2010-11-21 20:34:29 +01:00
parent f6f96ae97c
commit 3137b37b01

View File

@ -90,10 +90,8 @@ def build_isbn(base_url, opts):
return base_url + 'index1=isbn&value1='+opts.isbn return base_url + 'index1=isbn&value1='+opts.isbn
def build_combined(base_url, opts): def build_combined(base_url, opts):
query = '' query = ' '.join([e for e in (opts.title, opts.author, opts.publisher) \
for e in (opts.title, opts.author, opts.publisher): if e is not None ])
if e is not None:
query += ' ' + e
query = query.strip() query = query.strip()
if len(query) == 0: if len(query) == 0:
raise ISBNDBError('You must specify at least one of --author, --title or --publisher') raise ISBNDBError('You must specify at least one of --author, --title or --publisher')
@ -139,17 +137,10 @@ def create_books(opts, args, timeout=5.):
if opts.verbose: if opts.verbose:
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 = [] #remove duplicates ISBN
for x in tans: return dict((book.isbn, book) for book in tans).values()
add = True
for y in ans:
if y.isbn == x.isbn:
add = False
if add:
ans.append(x)
return ans
def main(args=sys.argv): def main(args=sys.argv):
parser = option_parser() parser = option_parser()