1
#!/usr/bin/env python2.4
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
2
18
from subprocess import Popen, PIPE
3
from urllib import urlencode
4
from xml.sax.saxutils import escape
11
24
RSVG_OUTPUT_TYPES = ('png', 'jpg')
12
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
25
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
15
28
class NoDot(Exception):
36
49
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)
49
71
if label is not None:
50
72
attributes.append('label="%s"' % label)
51
73
attributes.append('shape="box"')
53
75
if self.message is not None:
54
tooltip += self.message.replace('"', '\\"')
56
attributes.append('tooltip="%s"' % tooltip)
76
tooltip = self.message
77
attributes.append(self.get_attribute('tooltip', tooltip))
57
78
if self.href is not None:
58
79
attributes.append('href="%s"' % self.href)
182
203
shutil.rmtree(tempdir)
185
def invoke_dot(input, out_file=None, file_type='svg', antialias=None,
206
def invoke_dot(input, out_file=None, file_type='svg', antialias=None,
186
207
fontname="Helvetica", fontsize=11):
187
cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
208
cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
188
209
'-Efontname=%s' % fontname, '-Nfontsize=%d' % fontsize,
189
210
'-Efontsize=%d' % fontsize]
190
211
if out_file is not None: