mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
...
This commit is contained in:
parent
8dd435ecdb
commit
4285654352
@ -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()
|
start_time = time.time()
|
||||||
plugins = list(metadata_plugins(['identify']))
|
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('Running identify query with parameters:')
|
||||||
log(kwargs)
|
log(kwargs)
|
||||||
log('Using plugins:', ', '.join([p.name for p in plugins]))
|
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]
|
workers = [Worker(p, kwargs, abort) for p in plugins]
|
||||||
for w in workers:
|
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():
|
for plugin, presults in results.iteritems():
|
||||||
presults.sort(key=plugin.identify_results_keygen(**sort_kwargs))
|
presults.sort(key=plugin.identify_results_keygen(**sort_kwargs))
|
||||||
plog = logs[plugin].getvalue().strip()
|
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('Request extra headers:', plugin.browser.addheaders)
|
||||||
log('Found %d results'%len(presults))
|
log('Found %d results'%len(presults))
|
||||||
if plog:
|
if plog:
|
||||||
@ -324,10 +324,10 @@ if __name__ == '__main__': # tests {{{
|
|||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
( # This isbn not on amazon
|
( # Test absence of identifiers
|
||||||
{'identifiers':{'isbn': '8324616489'}, 'title':'Learning Python',
|
{'title':'Learning Python',
|
||||||
'authors':['Lutz']},
|
'authors':['Lutz']},
|
||||||
[title_test('Learning Python, 3rd Edition',
|
[title_test('Learning Python',
|
||||||
exact=True), authors_test(['Mark Lutz'])
|
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)
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -69,6 +69,9 @@ def test_identify(tests): # {{{
|
|||||||
times = []
|
times = []
|
||||||
|
|
||||||
for kwargs, test_funcs in tests:
|
for kwargs, test_funcs in tests:
|
||||||
|
log('#'*80)
|
||||||
|
log('### Running test with:', kwargs)
|
||||||
|
log('#'*80)
|
||||||
prints('Running test with:', kwargs)
|
prints('Running test with:', kwargs)
|
||||||
args = (log, abort)
|
args = (log, abort)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
@ -108,10 +111,11 @@ def test_identify(tests): # {{{
|
|||||||
prints('Most relevant result failed the tests')
|
prints('Most relevant result failed the tests')
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
log('\n\n')
|
||||||
|
|
||||||
prints('Average time per query', sum(times)/len(times))
|
prints('Average time per query', sum(times)/len(times))
|
||||||
|
|
||||||
if os.stat(lf).st_size > 10:
|
prints('Full log is at:', lf)
|
||||||
prints('There were some errors/warnings, see log', lf)
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user