From 186ec3f89806fc3d5532b171c7ae34b06059c491 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 20 Apr 2018 19:21:40 +0300 Subject: Refactor: icktool --- icktool | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'icktool') diff --git a/icktool b/icktool index 6e493d1..7be5bc1 100755 --- a/icktool +++ b/icktool @@ -192,31 +192,30 @@ class Icktool(cliapp.Application): current = build['current_action'] status = build['status'] + f = self.output + f.write('digraph "build_graph" {\n') + for i, action in enumerate(actions): + self._describe_node(f, i, current, action) + f.write('}\n') + + def _describe_node(self, f, i, current, action): styles = { 'done': ('rectangle', '#ffffff'), 'building': ('ellipse', '#00ff00'), 'blocked': ('ellipse', '#bbbbbb'), } - node_tmpl = 'a{} [label="{}" shape={} style=filled fillcolor="{}"]\n' - - f = self.output - f.write('digraph "build_graph" {\n') - for i, action in enumerate(actions): - if current is None: - shape, color = styles['done'] - elif i < current: - shape, color = styles['done'] - elif i == current: - shape, color = styles['building'] - elif i > current: - shape, color = styles['blocked'] - f.write( - node_tmpl.format( - i, self._describe_action(action), shape, color)) - if i > 0: - f.write('a{} -> a{}\n'.format(i-1, i)) - f.write('}\n') + if current is None: + shape, color = styles['done'] + elif i < current: + shape, color = styles['done'] + elif i == current: + shape, color = styles['building'] + elif i > current: + shape, color = styles['blocked'] + + tmpl = 'a{} [label="{}" shape={} style=filled fillcolor="{}"]\n' + f.write(tmpl.format(i, self._describe_action(action), shape, color)) def _describe_action(self, action): for key in ['action', 'archive']: -- cgit v1.2.1