From 81b917db42a185d11511dc0f972397459b1593d5 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 24 Aug 2010 11:42:30 -0600 Subject: [PATCH] Conversion pipeline: Don't fail if parsing extra css raises an exception. Instead just ignore it. --- src/calibre/ebooks/oeb/stylizer.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index f465935376..d10ea12394 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -168,12 +168,18 @@ class Stylizer(object): item.href)) continue stylesheets.append(sitem.data) - for x in (extra_css, user_css): + csses = {'extra_css':extra_css, 'user_css':user_css} + for w, x in csses.items(): if x: - text = XHTML_CSS_NAMESPACE + x - stylesheet = parser.parseString(text, href=cssname) - stylesheet.namespaces['h'] = XHTML_NS - stylesheets.append(stylesheet) + try: + text = XHTML_CSS_NAMESPACE + x + stylesheet = parser.parseString(text, href=cssname) + stylesheet.namespaces['h'] = XHTML_NS + stylesheets.append(stylesheet) + except: + self.logger.exception('Failed to parse %s, ignoring.'%w) + self.logger.debug('Bad css: ') + self.logger.debug(x) rules = [] index = 0 self.stylesheets = set()