Attachment 'graphviz-encoding.patch'

Download

   1 --- GraphvizParser-0.2/parsers/graphviz.py	2012-03-05 12:54:54.319015539 -0500
   2 +++ graphviz.py	2012-03-05 12:54:52.548965225 -0500
   3 @@ -1,4 +1,4 @@
   4 -# -*- coding: iso-8859-1 -*-
   5 +# -*- coding: utf-8 -*-
   6  """
   7      MoinMoin - Graphviz Parser
   8      Based loosely on GNUPLOT parser by MoinMoin:KwonChanYoung
   9 @@ -13,13 +13,15 @@ __version__ = "0.2"
  10  # Change this to the directory that the Graphviz binaries (dot, neato, etc.)
  11  # are installed in.
  12  
  13 -BINARY_PATH = '/usr/bin'
  14 +BINARY_PATH = '/usr/bin/'
  15  
  16  from os.path import join
  17  import os
  18  import subprocess
  19  import sha
  20  import re
  21 +import sys
  22 +import StringIO
  23  
  24  from MoinMoin import config
  25  from MoinMoin.action import AttachFile
  26 @@ -113,7 +115,7 @@ class Parser:
  27              logging.warn('format %s is incompatible with cmapx option' % format)
  28              cmapx = None
  29  
  30 -        digest = sha.new(self.raw).hexdigest()
  31 +        digest = sha.new(self.raw.encode('utf-8')).hexdigest()
  32  
  33          # Make sure that an attachments directory exists and that old graphs are
  34          # deleted.
  35 @@ -232,23 +234,19 @@ class Parser:
  36                  stdout=subprocess.PIPE,
  37                  stderr=subprocess.PIPE)
  38  
  39 -        p.stdin.write(graph_def)
  40 -        p.stdin.flush()
  41 -        p.stdin.close()
  42 -
  43 -        p.wait()
  44 +        (stdoutdata, stderrdata) = p.communicate(input=graph_def.encode('utf-8'))
  45  
  46          # Graph data always goes via standard output so that we can extract the
  47          # width and height if possible.
  48  
  49          if need_output:
  50 -            output, attrs = self.process_output(p.stdout, format)
  51 +            output, attrs = self.process_output(StringIO.StringIO(stdoutdata), format)
  52          else:
  53              output, attrs = None, {}
  54  
  55          # Test for errors.
  56  
  57 -        errors = p.stderr.read()
  58 +        errors = stderrdata
  59  
  60          if len(errors) > 0:
  61              raise GraphVizError, errors
  62 @@ -289,7 +287,7 @@ class Parser:
  63          found = False
  64          attrs = {}
  65  
  66 -        for line in output.xreadlines():
  67 +        for line in output.readlines():
  68              if not found and line.startswith("<svg "):
  69                  for match in self.attr_regexp.finditer(line):
  70                      attrs[match.group("attr")] = match.group("value")

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-03-06 23:47:57, 11.2 KB) [[attachment:GraphvizParser-0.2.1.tar.bz2]]
  • [get | view] (2012-03-22 22:10:56, 11.5 KB) [[attachment:GraphvizParser-0.2.2.tar.bz2]]
  • [get | view] (2012-04-18 22:49:01, 11.5 KB) [[attachment:GraphvizParser-0.2.3.tar.bz2]]
  • [get | view] (2012-01-14 20:05:02, 11.1 KB) [[attachment:GraphvizParser-0.2.tar.bz2]]
  • [get | view] (2012-03-05 18:03:40, 2.2 KB) [[attachment:graphviz-encoding.patch]]
  • [get | view] (2008-11-01 19:09:07, 7.3 KB) [[attachment:graphviz_0.1.py]]
  • [get | view] (2011-09-19 22:05:44, 3.1 KB) [[attachment:patch-svg.diff]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.