mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add option to metadata plugin tester to ignore failed fields
This commit is contained in:
parent
bba964e903
commit
bef20cf124
@ -167,7 +167,8 @@ def test_identify(tests): # {{{
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None): # {{{
|
def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None,
|
||||||
|
fail_missing_meta=True): # {{{
|
||||||
'''
|
'''
|
||||||
:param name: Plugin name
|
:param name: Plugin name
|
||||||
:param tests: List of 2-tuples. Each two tuple is of the form (args,
|
:param tests: List of 2-tuples. Each two tuple is of the form (args,
|
||||||
@ -246,7 +247,8 @@ def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None): # {{{
|
|||||||
None]
|
None]
|
||||||
if not good:
|
if not good:
|
||||||
prints('Failed to find', plugin.test_fields(possibles[0]))
|
prints('Failed to find', plugin.test_fields(possibles[0]))
|
||||||
raise SystemExit(1)
|
if fail_missing_meta:
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
if results[0] is not possibles[0]:
|
if results[0] is not possibles[0]:
|
||||||
prints('Most relevant result failed the tests')
|
prints('Most relevant result failed the tests')
|
||||||
@ -263,21 +265,22 @@ def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None): # {{{
|
|||||||
results.append(rq.get_nowait())
|
results.append(rq.get_nowait())
|
||||||
except Empty:
|
except Empty:
|
||||||
break
|
break
|
||||||
if not results:
|
if not results and fail_missing_meta:
|
||||||
prints('Cover download failed')
|
prints('Cover download failed')
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
cdata = results[0]
|
elif results:
|
||||||
cover = os.path.join(tdir, plugin.name.replace(' ',
|
cdata = results[0]
|
||||||
'')+'-%s-cover.jpg'%sanitize_file_name2(mi.title.replace(' ',
|
cover = os.path.join(tdir, plugin.name.replace(' ',
|
||||||
'_')))
|
'')+'-%s-cover.jpg'%sanitize_file_name2(mi.title.replace(' ',
|
||||||
with open(cover, 'wb') as f:
|
'_')))
|
||||||
f.write(cdata[-1])
|
with open(cover, 'wb') as f:
|
||||||
|
f.write(cdata[-1])
|
||||||
|
|
||||||
prints('Cover downloaded to:', cover)
|
prints('Cover downloaded to:', cover)
|
||||||
|
|
||||||
if len(cdata[-1]) < 10240:
|
if len(cdata[-1]) < 10240:
|
||||||
prints('Downloaded cover too small')
|
prints('Downloaded cover too small')
|
||||||
raise SystemExit(1)
|
raise SystemExit(1)
|
||||||
|
|
||||||
prints('Average time per query', sum(times)/len(times))
|
prints('Average time per query', sum(times)/len(times))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user