mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove unused css: Prevent failure when book has invalid items marked as stylesheets
This commit is contained in:
parent
d76dd915a2
commit
5ee7a620ea
@ -120,7 +120,13 @@ def preserve_htmlns_prefix(sheet, prefix):
|
|||||||
|
|
||||||
def remove_unused_css(container, report):
|
def remove_unused_css(container, report):
|
||||||
from cssutils.css import CSSRule
|
from cssutils.css import CSSRule
|
||||||
sheets = {name:container.parsed(name) for name, mt in container.mime_map.iteritems() if mt in OEB_STYLES}
|
def safe_parse(name):
|
||||||
|
try:
|
||||||
|
return container.parsed(name)
|
||||||
|
except TypeError:
|
||||||
|
pass
|
||||||
|
sheets = {name:safe_parse(name) for name, mt in container.mime_map.iteritems() if mt in OEB_STYLES}
|
||||||
|
sheets = {k:v for k, v in sheets.iteritems() if v is not None}
|
||||||
sheet_namespace = {}
|
sheet_namespace = {}
|
||||||
for sheet in sheets.itervalues():
|
for sheet in sheets.itervalues():
|
||||||
sheet_namespace[sheet] = process_namespaces(sheet)
|
sheet_namespace[sheet] = process_namespaces(sheet)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user