mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allowing controlling if trying to get missing resources from a plugin prints a traceback
This commit is contained in:
parent
a35ff73ced
commit
ef6c2b439f
@ -28,7 +28,7 @@ from polyglot.builtins import itervalues, reload, string_or_bytes
|
|||||||
# have non ASCII characters
|
# have non ASCII characters
|
||||||
|
|
||||||
|
|
||||||
def get_resources(zfp, name_or_list_of_names):
|
def get_resources(zfp, name_or_list_of_names, print_tracebacks_for_missing_resources=True):
|
||||||
'''
|
'''
|
||||||
Load resources from the plugin zip file
|
Load resources from the plugin zip file
|
||||||
|
|
||||||
@ -49,15 +49,16 @@ def get_resources(zfp, name_or_list_of_names):
|
|||||||
try:
|
try:
|
||||||
ans[name] = zf.read(name)
|
ans[name] = zf.read(name)
|
||||||
except:
|
except:
|
||||||
import traceback
|
if print_tracebacks_for_missing_resources:
|
||||||
traceback.print_exc()
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
if len(names) == 1:
|
if len(names) == 1:
|
||||||
ans = ans.pop(names[0], None)
|
ans = ans.pop(names[0], None)
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
def get_icons(zfp, name_or_list_of_names, plugin_name=''):
|
def get_icons(zfp, name_or_list_of_names, plugin_name='', print_tracebacks_for_missing_resources=True):
|
||||||
'''
|
'''
|
||||||
Load icons from the plugin zip file
|
Load icons from the plugin zip file
|
||||||
|
|
||||||
@ -86,7 +87,7 @@ def get_icons(zfp, name_or_list_of_names, plugin_name=''):
|
|||||||
else:
|
else:
|
||||||
failed = set(namelist)
|
failed = set(namelist)
|
||||||
if failed:
|
if failed:
|
||||||
from_zfp = get_resources(zfp, list(failed))
|
from_zfp = get_resources(zfp, list(failed), print_tracebacks_for_missing_resources=print_tracebacks_for_missing_resources)
|
||||||
if from_zfp is None:
|
if from_zfp is None:
|
||||||
from_zfp = {}
|
from_zfp = {}
|
||||||
elif isinstance(from_zfp, string_or_bytes):
|
elif isinstance(from_zfp, string_or_bytes):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user