~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to dotgraph.py

  • Committer: Aaron Bentley
  • Date: 2005-10-24 04:07:55 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20051024040755-2b574c6aff8ac6d2
Added blackbox tests for bzrtools

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005 Aaron Bentley
2
 
# <aaron.bentley@utoronto.ca>
3
 
#
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.
8
 
#
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.
13
 
#
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
17
 
 
 
1
#!/usr/bin/env python2.4
18
2
from subprocess import Popen, PIPE
19
3
from urllib import urlencode
20
4
from xml.sax.saxutils import escape
25
9
import time
26
10
 
27
11
RSVG_OUTPUT_TYPES = ('png', 'jpg')
28
 
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png',
 
12
DOT_OUTPUT_TYPES = ('svg', 'svgz', 'gif', 'jpg', 'ps', 'fig', 'mif', 'png', 
29
13
                    'cmapx')
30
14
 
31
15
class NoDot(Exception):
198
182
        shutil.rmtree(tempdir)
199
183
    return status
200
184
 
201
 
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, 
202
186
               fontname="Helvetica", fontsize=11):
203
 
    cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname,
 
187
    cmdline = ['dot', '-T%s' % file_type, '-Nfontname=%s' % fontname, 
204
188
               '-Efontname=%s' % fontname, '-Nfontsize=%d' % fontsize,
205
189
               '-Efontsize=%d' % fontsize]
206
190
    if out_file is not None:
213
197
        else:
214
198
            raise
215
199
    for line in input:
216
 
        dot_proc.stdin.write(line.encode('utf-8'))
 
200
        dot_proc.stdin.write(line)
217
201
    dot_proc.stdin.close()
218
202
    return dot_proc.wait()
219
203