def _build_graph(self, req, tkt_ids, label_summary=0):
        g = graphviz.Graph()
        g.label_summary = label_summary

        g.attributes['rankdir'] = self.graph_direction
        
        node_default = g['node']
        node_default['style'] = 'filled'
        
        edge_default = g['edge']
        edge_default['style'] = ''
        
        # Force this to the top of the graph
        for id in tkt_ids:
            g[id] 
        
        links = TicketLinks.walk_tickets(self.env, tkt_ids)
        links = sorted(links, key=lambda link: link.tkt.id)
        for link in links:
            tkt = link.tkt
            node = g[tkt.id]
            if label_summary:
                node['label'] = u'#%s %s' % (tkt.id, tkt['summary'])
            else:
                node['label'] = u'#%s'%tkt.id
            node['fillcolor'] = tkt['status'] == 'closed' and self.closed_color or self.opened_color
            node['URL'] = req.href.ticket(tkt.id)
            node['alt'] = u'Ticket #%s'%tkt.id
            node['tooltip'] = tkt['summary']
            
            for n in link.blocking:
                node > g[n]
        
        return g
Example #2
0
    def _build_graph(self, req, tkt_ids, label_summary=0):
        g = graphviz.Graph()
        g.label_summary = label_summary

        g.attributes['rankdir'] = self.graph_direction

        node_default = g['node']
        node_default['style'] = 'filled'

        edge_default = g['edge']
        edge_default['style'] = ''

        # Force this to the top of the graph
        for id in tkt_ids:
            g[id]

        links = TicketLinks.walk_tickets(self.env, tkt_ids)
        links = sorted(links, key=lambda link: link.tkt.id)
        for link in links:
            tkt = link.tkt
            node = g[tkt.id]
            if label_summary:
                node['label'] = u'#%s %s' % (tkt.id, tkt['summary'])
            else:
                node['label'] = u'#%s' % tkt.id
            node['fillcolor'] = tkt[
                'status'] == 'closed' and self.closed_color or self.opened_color
            node['URL'] = req.href.ticket(tkt.id)
            node['alt'] = u'Ticket #%s' % tkt.id
            node['tooltip'] = tkt['summary']

            for n in link.blocking:
                node > g[n]

        return g
Example #3
0
    def _build_graph(self, req, tkt_ids, label_summary=0):
        g = graphviz.Graph(log=self.log)
        g.label_summary = label_summary

        g.attributes['rankdir'] = self.graph_direction

        node_default = g['node']
        node_default['style'] = 'filled'

        edge_default = g['edge']
        edge_default['style'] = ''

        # Force this to the top of the graph
        for tid in tkt_ids:
            g[tid]

        if self.show_key:
            g[-1]['label'] = self.closed_text
            g[-1]['fillcolor'] = self.closed_color
            g[-1]['shape'] = 'box'
            g[-2]['label'] = self.opened_text
            g[-2]['fillcolor'] = self.opened_color
            g[-2]['shape'] = 'box'

        links = TicketLinks.walk_tickets(self.env, tkt_ids, self.full_graph)
        links = sorted(links, key=lambda link: link.tkt.id)
        for link in links:
            tkt = link.tkt
            node = g[tkt.id]
            if label_summary:
                node['label'] = u'#%s %s' % (tkt.id, tkt['summary'])
            else:
                node['label'] = u'#%s' % tkt.id
            node['fillcolor'] = tkt['status'] == 'closed' and \
                                self.closed_color or self.opened_color
            node['URL'] = req.href.ticket(tkt.id)
            node['alt'] = u'Ticket #%s' % tkt.id
            node['tooltip'] = escape(tkt['summary'])
            if self.highlight_target and tkt.id in tkt_ids:
                node['penwidth'] = 3

            for n in link.blocking:
                node > g[n]

        return g
    def _build_graph(self, req, tkt_ids, label_summary=0):
        g = graphviz.Graph(log=self.log)
        g.label_summary = label_summary

        g.attributes['rankdir'] = self.graph_direction

        node_default = g['node']
        node_default['style'] = 'filled'

        edge_default = g['edge']
        edge_default['style'] = ''

        # Force this to the top of the graph
        for id in tkt_ids:
            g[id]

        if self.show_key:
            g[-1]['label'] = self.closed_text
            g[-1]['fillcolor'] = self.closed_color
            g[-1]['shape'] = 'box'
            g[-2]['label'] = self.opened_text
            g[-2]['fillcolor'] = self.opened_color
            g[-2]['shape'] = 'box'

        links = TicketLinks.walk_tickets(self.env, tkt_ids,
                                         full=self.full_graph)
        links = sorted(links, key=lambda link: link.tkt.id)
        for link in links:
            tkt = link.tkt
            node = g[tkt.id]
            if label_summary:
                node['label'] = u'#%s %s' % (tkt.id, tkt['summary'])
            else:
                node['label'] = u'#%s' % tkt.id
            node['fillcolor'] = tkt['status'] == 'closed' and self.closed_color or self.opened_color
            node['URL'] = req.href.ticket(tkt.id)
            node['alt'] = u'Ticket #%s' % tkt.id
            node['tooltip'] = escape(tkt['summary'])
            if self.highlight_target and tkt.id in tkt_ids:
                node['penwidth'] = 3

            for n in link.blocking:
                node > g[n]

        return g
Example #5
0
    def _build_graph(self, req, tkt_ids, label_summary=0, with_clusters=False):
        g = graphviz.Graph()
        g.label_summary = label_summary

        g.attributes.update({
            'rankdir': self.graph_direction,
        })

        node_default = g['node']
        node_default.update({
            'style': 'filled',
            'fontsize': 11,
            'fontname': 'Arial',
            'shape': 'box' if label_summary else 'ellipse',
            'target': '_blank',
        })

        edge_default = g['edge']
        edge_default['style'] = ''

        width = 20
        def q(text):
            return textwrap.fill(text, width).replace('"', '\\"').replace('\n', '\\n')

        def create_node(tkt):
            node = g.get_node(tkt.id)
            summary = q(tkt['summary'])
            if label_summary:
                node['label'] = u'#%s %s' % (tkt.id, summary)
            else:
                node['label'] = u'#%s'%tkt.id
            if tkt['status'] == 'closed':
                color = tkt['resolution'] in bc_resolutions and self.bad_closed_color or self.closed_color
            else:
                color = self.opened_color
            node['fillcolor'] = color
            node['URL'] = req.href.ticket(tkt.id)
            node['alt'] = _('Ticket #%(id)s', id=tkt.id)
            node['tooltip'] = summary.replace('\\n', ' 
')
            return node

        ticket_cache = {}

        if with_clusters:
            milestone_tkt_ids = sorted(tkt_ids)
            tkt_ids = []
            tickets = {} # { <milestone_name or None>: (<cluster or graph>, <tkt_ids list>), ... }
            ticket_milestones = {} # { <tkt_id>: <milestone> }
            m_idx = 0
            for milestone, mtkt_ids in itertools.groupby(milestone_tkt_ids, lambda p: p[0]):
                ids = [p[1] for p in mtkt_ids]
                if milestone:
                    m_idx += 1
                    url = req.href.depgraph(get_resource_url(self.env,
                                            Resource('milestone', milestone, pid=req.data['project_id'])))
                    tickets[milestone] = (g.create_cluster(
                            u'cluster%s' % m_idx,
                            label=q(milestone),
                            href=url, target='_blank'),
                                          ids)
                else:
                    milestone = None
                    tickets[None] = (g, ids)
                tkt_ids.extend(ids)
                for tkt_id in ids:
                    ticket_milestones[tkt_id] = milestone
        else:
            # Init nodes for resource tickets on graph top
            for id in tkt_ids:
                g[id]

        bc_resolutions = self.bad_closed_resolutions.syllabus(req.data['syllabus_id'])
        links = TicketLinks.walk_tickets(self.env, tkt_ids, ticket_cache)
        links = sorted(links, key=lambda link: link.tkt.id)
        for link in links:
            node = create_node(link.tkt)

            if with_clusters:
                milestone_from = link.tkt['milestone'] or None
                stor = tickets[milestone_from][0]
                stor[link.tkt.id] # include node
                for n in link.blocking:
                    milestone_to = ticket_milestones[n]
                    if milestone_from == milestone_to:
                        stor.add(node > stor[n]) # save edge in same cluster
                    else:
                        g.add(node > tickets[milestone_to][0][n]) # save edge in global graph
            else:
                g[link.tkt.id]
                for n in link.blocking:
                    g.add(node > g[n])

        return g