~lifeless/bzrtools/trunk

« back to all changes in this revision

Viewing changes to dotgraph.py

  • Committer: Robert Collins
  • Date: 2008-07-08 04:11:21 UTC
  • mfrom: (623.1.33 bzrtools)
  • Revision ID: robertc@robertcollins.net-20080708041121-lo0k7os2y03uclt2
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        self.message = message
50
50
        self.href = None
51
51
 
 
52
    @staticmethod
 
53
    def get_attribute(name, value):
 
54
        if value is None:
 
55
            return ''
 
56
        value = value.replace("\\", "\\\\")
 
57
        value = value.replace('"', '\\"')
 
58
        value = value.replace('\n', '\\n')
 
59
        return '%s="%s"' % (name, value)
 
60
 
52
61
    def define(self):
53
62
        attributes = []
54
63
        style = []
62
71
        if label is not None:
63
72
            attributes.append('label="%s"' % label)
64
73
        attributes.append('shape="box"')
65
 
        tooltip = ''
 
74
        tooltip = None
66
75
        if self.message is not None:
67
 
            tooltip += self.message.replace('"', '\\"')
68
 
        if tooltip:
69
 
            attributes.append('tooltip="%s"' % tooltip)
 
76
            tooltip = self.message
 
77
        attributes.append(self.get_attribute('tooltip', tooltip))
70
78
        if self.href is not None:
71
79
            attributes.append('href="%s"' % self.href)
72
80
        elif tooltip: