1.1 --- a/parsers/graphviz.py Sat Jan 14 21:04:42 2012 +0100
1.2 +++ b/parsers/graphviz.py Wed Mar 07 00:48:28 2012 +0100
1.3 @@ -1,21 +1,23 @@
1.4 -# -*- coding: iso-8859-1 -*-
1.5 +# -*- coding: utf-8 -*-
1.6 """
1.7 MoinMoin - Graphviz Parser
1.8 Based loosely on GNUPLOT parser by MoinMoin:KwonChanYoung
1.9
1.10 @copyright: 2008 Wayne Tucker
1.11 @copyright: 2011, 2012 Paul Boddie <paul@boddie.org.uk>
1.12 + @copyright: 2012 Frederick Capovilla (Libéo) <fcapovilla@live.ca>
1.13 @license: GNU GPL, see COPYING for details.
1.14 """
1.15
1.16 -__version__ = "0.2"
1.17 +__version__ = "0.2.1"
1.18
1.19 # Change this to the directory that the Graphviz binaries (dot, neato, etc.)
1.20 # are installed in.
1.21
1.22 -BINARY_PATH = '/usr/bin'
1.23 +BINARY_PATH = '/usr/bin/'
1.24
1.25 from os.path import join
1.26 +from StringIO import StringIO
1.27 import os
1.28 import subprocess
1.29 import sha
1.30 @@ -113,7 +115,7 @@
1.31 logging.warn('format %s is incompatible with cmapx option' % format)
1.32 cmapx = None
1.33
1.34 - digest = sha.new(self.raw).hexdigest()
1.35 + digest = sha.new(self.raw.encode('utf-8')).hexdigest()
1.36
1.37 # Make sure that an attachments directory exists and that old graphs are
1.38 # deleted.
1.39 @@ -232,23 +234,19 @@
1.40 stdout=subprocess.PIPE,
1.41 stderr=subprocess.PIPE)
1.42
1.43 - p.stdin.write(graph_def)
1.44 - p.stdin.flush()
1.45 - p.stdin.close()
1.46 -
1.47 - p.wait()
1.48 + (stdoutdata, stderrdata) = p.communicate(input=graph_def.encode('utf-8'))
1.49
1.50 # Graph data always goes via standard output so that we can extract the
1.51 # width and height if possible.
1.52
1.53 if need_output:
1.54 - output, attrs = self.process_output(p.stdout, format)
1.55 + output, attrs = self.process_output(StringIO(stdoutdata), format)
1.56 else:
1.57 output, attrs = None, {}
1.58
1.59 # Test for errors.
1.60
1.61 - errors = p.stderr.read()
1.62 + errors = stderrdata
1.63
1.64 if len(errors) > 0:
1.65 raise GraphVizError, errors
1.66 @@ -289,7 +287,7 @@
1.67 found = False
1.68 attrs = {}
1.69
1.70 - for line in output.xreadlines():
1.71 + for line in output.readlines():
1.72 if not found and line.startswith("<svg "):
1.73 for match in self.attr_regexp.finditer(line):
1.74 attrs[match.group("attr")] = match.group("value")