1
# Copyright (C) 2004, 2005 Aaron Bentley
2
# <aaron@aaronbentley.com>
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1
#!/usr/bin/env python2.4
18
2
from subprocess import Popen, PIPE
3
from urllib import urlencode
4
from xml.sax.saxutils import escape
24
11
RSVG_OUTPUT_TYPES = ('png', 'jpg')
25
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
12
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
28
15
class NoDot(Exception):
49
36
self.message = message
53
def get_attribute(name, value):
56
value = value.replace("\\", "\\\\")
57
value = value.replace('"', '\\"')
58
value = value.replace('\n', '\\n')
59
return '%s="%s"' % (name, value)
71
49
if label is not None:
72
50
attributes.append('label="%s"' % label)
73
51
attributes.append('shape="box"')
75
53
if self.message is not None:
76
tooltip = self.message
77
attributes.append(self.get_attribute('tooltip', tooltip))
54
tooltip += self.message.replace('"', '\\"')
56
attributes.append('tooltip="%s"' % tooltip)
78
57
if self.href is not None:
79
58
attributes.append('href="%s"' % self.href)
203
182
shutil.rmtree(tempdir)
206
def invoke_dot(input, out_file=None, file_type='svg', antialias=None,
185
def invoke_dot(input, out_file=None, file_type='svg', antialias=None,
207
186
fontname="Helvetica", fontsize=11):
208
cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
187
cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
209
188
'-Efontname=%s' % fontname, '-Nfontsize=%d' % fontsize,
210
189
'-Efontsize=%d' % fontsize]
211
190
if out_file is not None: