diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-04-20 19:21:40 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-04-20 19:21:40 +0300 |
commit | 186ec3f89806fc3d5532b171c7ae34b06059c491 (patch) | |
tree | 3119c70c36b784d3b9dc4b36e7ab4c7ce829c913 /icktool | |
parent | a22fce407a7b873d7590cf87db99ce58a169eb5f (diff) | |
download | ick2-186ec3f89806fc3d5532b171c7ae34b06059c491.tar.gz |
Refactor: icktool
Diffstat (limited to 'icktool')
-rwxr-xr-x | icktool | 37 |
1 files changed, 18 insertions, 19 deletions
@@ -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']: |