From 42856543527e198e109de8f713cdf2586f06f906 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Apr 2011 11:52:52 -0600 Subject: [PATCH] ... --- src/calibre/ebooks/metadata/sources/identify.py | 15 ++++++++------- src/calibre/ebooks/metadata/sources/test.py | 8 ++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index b65e97a10d..322a61bd83 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -208,7 +208,7 @@ def merge_identify_results(result_map, log): # }}} -def identify(log, abort, title=None, authors=None, identifiers=[], timeout=30): +def identify(log, abort, title=None, authors=None, identifiers={}, timeout=30): start_time = time.time() plugins = list(metadata_plugins(['identify'])) @@ -222,7 +222,7 @@ def identify(log, abort, title=None, authors=None, identifiers=[], timeout=30): log('Running identify query with parameters:') log(kwargs) log('Using plugins:', ', '.join([p.name for p in plugins])) - log('The log (if any) from individual plugins is below') + log('The log from individual plugins is below') workers = [Worker(p, kwargs, abort) for p in plugins] for w in workers: @@ -273,7 +273,7 @@ def identify(log, abort, title=None, authors=None, identifiers=[], timeout=30): for plugin, presults in results.iteritems(): presults.sort(key=plugin.identify_results_keygen(**sort_kwargs)) plog = logs[plugin].getvalue().strip() - log('\n'+'*'*35, plugin.name, '*'*35) + log('\n'+'*'*30, plugin.name, '*'*30) log('Request extra headers:', plugin.browser.addheaders) log('Found %d results'%len(presults)) if plog: @@ -324,10 +324,10 @@ if __name__ == '__main__': # tests {{{ ), - ( # This isbn not on amazon - {'identifiers':{'isbn': '8324616489'}, 'title':'Learning Python', + ( # Test absence of identifiers + {'title':'Learning Python', 'authors':['Lutz']}, - [title_test('Learning Python, 3rd Edition', + [title_test('Learning Python', exact=True), authors_test(['Mark Lutz']) ] @@ -353,6 +353,7 @@ if __name__ == '__main__': # tests {{{ ), ] - test_identify(tests[4:5]) + #test_identify(tests[1:2]) + test_identify(tests) # }}} diff --git a/src/calibre/ebooks/metadata/sources/test.py b/src/calibre/ebooks/metadata/sources/test.py index 428da3ef65..2e72f86c47 100644 --- a/src/calibre/ebooks/metadata/sources/test.py +++ b/src/calibre/ebooks/metadata/sources/test.py @@ -69,6 +69,9 @@ def test_identify(tests): # {{{ times = [] for kwargs, test_funcs in tests: + log('#'*80) + log('### Running test with:', kwargs) + log('#'*80) prints('Running test with:', kwargs) args = (log, abort) start_time = time.time() @@ -108,10 +111,11 @@ def test_identify(tests): # {{{ prints('Most relevant result failed the tests') raise SystemExit(1) + log('\n\n') + prints('Average time per query', sum(times)/len(times)) - if os.stat(lf).st_size > 10: - prints('There were some errors/warnings, see log', lf) + prints('Full log is at:', lf) # }}}