diff --git a/src/calibre/ebooks/metadata/sources/amazon.py b/src/calibre/ebooks/metadata/sources/amazon.py index 9460ed7ace..6b30a0cd2e 100644 --- a/src/calibre/ebooks/metadata/sources/amazon.py +++ b/src/calibre/ebooks/metadata/sources/amazon.py @@ -41,7 +41,7 @@ class Worker(Thread): # {{{ try: self.get_details() except: - self.log.error('get_details failed for url: %r'%self.url) + self.log.exception('get_details failed for url: %r'%self.url) def get_details(self): try: @@ -168,7 +168,7 @@ class Worker(Thread): # {{{ if self.isbn: self.plugin.cache_isbn_to_identifier(self.isbn, self.amazon_id) if self.cover_url: - self.cache_identifier_to_cover_url(self.amazon_id, + self.plugin.cache_identifier_to_cover_url(self.amazon_id, self.cover_url) self.result_queue.put(mi) diff --git a/src/calibre/ebooks/metadata/sources/test.py b/src/calibre/ebooks/metadata/sources/test.py index 032041ef29..62b00851de 100644 --- a/src/calibre/ebooks/metadata/sources/test.py +++ b/src/calibre/ebooks/metadata/sources/test.py @@ -10,7 +10,7 @@ __docformat__ = 'restructuredtext en' import os, tempfile, time from Queue import Queue, Empty from threading import Event - +from functools import partial from calibre.customize.ui import metadata_plugins from calibre import prints @@ -90,11 +90,17 @@ def test_identify_plugin(name, tests): except Empty: break - prints('Found', len(results), 'matches:') + prints('Found', len(results), 'matches:', end=' ') + prints('Smaller relevance means better match') - for mi in results: + results.sort(cmp=partial(plugin.compare_identify_results, + title=kwargs.get('title', None), authors=kwargs.get('authors', + None), identifiers=kwargs.get('identifiers', {}))) + + for i, mi in enumerate(results): + prints('*'*30, 'Relevance:', i, '*'*30) prints(mi) - prints('\n\n') + prints('*'*75, '\n\n') possibles = [] for mi in results: @@ -117,6 +123,9 @@ def test_identify_plugin(name, tests): prints('Failed to find', plugin.test_fields(possibles[0])) raise SystemExit(1) + if results[0] is not possibles[0]: + prints('Most relevant result failed the tests') + prints('Average time per query', sum(times)/len(times))