From ee6fc5c15bdbe975625ee2211986770b98aca9c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 26 Feb 2010 00:41:00 -0700 Subject: [PATCH] MOBI Output: If the SVG rasterizer is not avaialbale continue anyway --- src/calibre/ebooks/mobi/output.py | 9 ++++++--- src/calibre/ebooks/oeb/transforms/rasterize.py | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/mobi/output.py b/src/calibre/ebooks/mobi/output.py index e3a1da34cc..451fe11e4f 100644 --- a/src/calibre/ebooks/mobi/output.py +++ b/src/calibre/ebooks/mobi/output.py @@ -154,7 +154,7 @@ class MOBIOutput(OutputFormatPlugin): MobiWriter, PALMDOC, UNCOMPRESSED from calibre.ebooks.mobi.mobiml import MobiMLizer from calibre.ebooks.oeb.transforms.manglecase import CaseMangler - from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer + from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable from calibre.ebooks.oeb.transforms.htmltoc import HTMLTOCAdder from calibre.customize.ui import plugin_for_input_format imagemax = PALM_MAX_IMAGE_SIZE if opts.rescale_images else None @@ -163,8 +163,11 @@ class MOBIOutput(OutputFormatPlugin): tocadder(oeb, opts) mangler = CaseMangler() mangler(oeb, opts) - rasterizer = SVGRasterizer() - rasterizer(oeb, opts) + try: + rasterizer = SVGRasterizer() + rasterizer(oeb, opts) + except Unavailable: + self.log.warn('SVG rasterizer unavailable, SVG will not be converted') mobimlizer = MobiMLizer(ignore_tables=opts.linearize_tables) mobimlizer(oeb, opts) self.check_for_periodical() diff --git a/src/calibre/ebooks/oeb/transforms/rasterize.py b/src/calibre/ebooks/oeb/transforms/rasterize.py index ac28e51b15..1026b625bf 100644 --- a/src/calibre/ebooks/oeb/transforms/rasterize.py +++ b/src/calibre/ebooks/oeb/transforms/rasterize.py @@ -27,11 +27,14 @@ from calibre.ebooks.oeb.stylizer import Stylizer IMAGE_TAGS = set([XHTML('img'), XHTML('object')]) KEEP_ATTRS = set(['class', 'style', 'width', 'height', 'align']) +class Unavailable(Exception): + pass + class SVGRasterizer(object): def __init__(self): from calibre.gui2 import is_ok_to_use_qt if not is_ok_to_use_qt(): - raise Exception('Not OK to use Qt') + raise Unavailable('Not OK to use Qt') @classmethod def config(cls, cfg):