# HG changeset patch # User Paul Boddie # Date 1331077708 -3600 # Node ID cedca431c02f77162d987fb1037f6a7128bb0cbf # Parent ff426ae8f4cd3bb266d9185a1f7d7bb38e634c28 Incorporated encoding and subprocess fixes from Frederick Capovilla. diff -r ff426ae8f4cd -r cedca431c02f README.txt --- a/README.txt Sat Jan 14 21:04:42 2012 +0100 +++ b/README.txt Wed Mar 07 00:48:28 2012 +0100 @@ -90,7 +90,9 @@ * Comments must start at the beginning of the graphviz block and at the beginning of their respective lines. They must also not contain any extra - whitespace surrounding the = sign. + whitespace surrounding the = sign. It would arguably be better if the + configuration of images were done using the argument notation employed by + other parsers. * SVG image sizing can only be done by extracting the dimensions from an uncompressed ("svg" format, not "svgz" format) output representation. diff -r ff426ae8f4cd -r cedca431c02f docs/COPYING.txt --- a/docs/COPYING.txt Sat Jan 14 21:04:42 2012 +0100 +++ b/docs/COPYING.txt Wed Mar 07 00:48:28 2012 +0100 @@ -3,6 +3,7 @@ Copyright (C) 2008 Wayne Tucker Copyright (C) 2011, 2012 Paul Boddie +Copyright (C) 2012 Frederick Capovilla (Libéo) This software is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as diff -r ff426ae8f4cd -r cedca431c02f parsers/graphviz.py --- a/parsers/graphviz.py Sat Jan 14 21:04:42 2012 +0100 +++ b/parsers/graphviz.py Wed Mar 07 00:48:28 2012 +0100 @@ -1,21 +1,23 @@ -# -*- coding: iso-8859-1 -*- +# -*- coding: utf-8 -*- """ MoinMoin - Graphviz Parser Based loosely on GNUPLOT parser by MoinMoin:KwonChanYoung @copyright: 2008 Wayne Tucker @copyright: 2011, 2012 Paul Boddie + @copyright: 2012 Frederick Capovilla (Libéo) @license: GNU GPL, see COPYING for details. """ -__version__ = "0.2" +__version__ = "0.2.1" # Change this to the directory that the Graphviz binaries (dot, neato, etc.) # are installed in. -BINARY_PATH = '/usr/bin' +BINARY_PATH = '/usr/bin/' from os.path import join +from StringIO import StringIO import os import subprocess import sha @@ -113,7 +115,7 @@ logging.warn('format %s is incompatible with cmapx option' % format) cmapx = None - digest = sha.new(self.raw).hexdigest() + digest = sha.new(self.raw.encode('utf-8')).hexdigest() # Make sure that an attachments directory exists and that old graphs are # deleted. @@ -232,23 +234,19 @@ stdout=subprocess.PIPE, stderr=subprocess.PIPE) - p.stdin.write(graph_def) - p.stdin.flush() - p.stdin.close() - - p.wait() + (stdoutdata, stderrdata) = p.communicate(input=graph_def.encode('utf-8')) # Graph data always goes via standard output so that we can extract the # width and height if possible. if need_output: - output, attrs = self.process_output(p.stdout, format) + output, attrs = self.process_output(StringIO(stdoutdata), format) else: output, attrs = None, {} # Test for errors. - errors = p.stderr.read() + errors = stderrdata if len(errors) > 0: raise GraphVizError, errors @@ -289,7 +287,7 @@ found = False attrs = {} - for line in output.xreadlines(): + for line in output.readlines(): if not found and line.startswith("