From 298ed34b5bcd89f821728bb5e1fd33f5d2adc721 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Tue, 24 Jan 2012 17:04:40 +0100 Subject: [PATCH] appy.pod: allow to import SVG files (requires installing imagemagick). --- pod/actions.py | 4 +++- pod/doc_importers.py | 33 +++++++++++++++++++++++++-------- pod/renderer.py | 2 +- shared/packaging.py | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/pod/actions.py b/pod/actions.py index 313720c..58b126f 100644 --- a/pod/actions.py +++ b/pod/actions.py @@ -127,6 +127,7 @@ class ForAction(BufferAction): BufferAction.__init__(self, name, buffer, expr, elem, minus, source, fromExpr) self.iter = iter # Name of the iterator variable used in the each loop + def do(self): context = self.buffer.env.context # Check self.exprResult type @@ -195,7 +196,8 @@ class ForAction(BufferAction): context[self.iter] = hiddenVariable else: if self.exprResult: - del context[self.iter] + if self.iter in context: # May not be the case on error. + del context[self.iter] class NullAction(BufferAction): '''Action that does nothing. Used in conjunction with a "from" clause, it diff --git a/pod/doc_importers.py b/pod/doc_importers.py index c377d2c..290421d 100644 --- a/pod/doc_importers.py +++ b/pod/doc_importers.py @@ -29,6 +29,8 @@ FILE_NOT_FOUND = "'%s' does not exist or is not a file." PDF_TO_IMG_ERROR = 'A PDF file could not be converted into images. Please ' \ 'ensure that Ghostscript (gs) is installed on your ' \ 'system and the "gs" program is in the path.' +CONVERT_ERROR = 'Program "convert", from imagemagick, must be installed and ' \ + 'in the path for converting a SVG file into a PNG file.' # ------------------------------------------------------------------------------ class DocImporter: @@ -186,7 +188,11 @@ def getSize(filePath, fileType): if len(buf) == 5: # else: invalid/corrupted GIF (bad header) x, y, u = struct.unpack("