summaryrefslogtreecommitdiff
path: root/icktool
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-04-20 19:21:40 +0300
committerLars Wirzenius <liw@liw.fi>2018-04-20 19:21:40 +0300
commit186ec3f89806fc3d5532b171c7ae34b06059c491 (patch)
tree3119c70c36b784d3b9dc4b36e7ab4c7ce829c913 /icktool
parenta22fce407a7b873d7590cf87db99ce58a169eb5f (diff)
downloadick2-186ec3f89806fc3d5532b171c7ae34b06059c491.tar.gz
Refactor: icktool
Diffstat (limited to 'icktool')
-rwxr-xr-xicktool37
1 files changed, 18 insertions, 19 deletions
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']: