~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to dotgraph.py

  • Committer: Aaron Bentley
  • Date: 2005-09-01 17:03:54 UTC
  • Revision ID: abentley@panoramicfeedback.com-20050901170354-d4284bd69b877fa5
Used rsvga for nice antialiasing

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from xml.sax.saxutils import escape
5
5
import os.path
6
6
import errno
 
7
import tempfile
 
8
import shutil
7
9
 
8
10
mail_map = {}
9
11
 
11
13
    def __init__(self):
12
14
        Exception.__init__(self, "Can't find dot!")
13
15
 
 
16
class NoRsvg(Exception):
 
17
    def __init__(self):
 
18
        Exception.__init__(self, "Can't find rsvg!")
 
19
 
14
20
class Node(object):
15
21
    def __init__(self, name, color=None, label=None, rev_id=None,
16
22
                 cluster=None):
108
114
            yield "}\n"
109
115
    yield "}\n"
110
116
 
 
117
def invoke_dot_aa(input, out_file, file_type='png'):
 
118
    """\
 
119
    Produce antialiased Dot output, invoking rsvg on an intermediate file.
 
120
    rsvg only supports png, jpeg and .ico files."""
 
121
    tempdir = tempfile.mkdtemp()
 
122
    try:
 
123
        temp_file = os.path.join(tempdir, 'temp.svg')
 
124
        invoke_dot(input, temp_file, 'svg')
 
125
        cmdline = ['rsvg', temp_file, out_file]
 
126
        try:
 
127
            rsvg_proc = Popen(cmdline)
 
128
        except OSError, e:
 
129
            if e.errno == errno.ENOENT:
 
130
                raise NoRsvg()
 
131
        status = rsvg_proc.wait()
 
132
    finally:
 
133
        shutil.rmtree(tempdir)
 
134
    return status
 
135
 
111
136
def invoke_dot(input, out_file=None, file_type='svg', antialias=None):
112
137
    cmdline = ['dot', '-T%s' % file_type]
113
138
    if out_file is not None: