summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@qvarnlabs.com>2018-12-31 11:20:39 +0200
committerLars Wirzenius <liw@qvarnlabs.com>2018-12-31 11:20:39 +0200
commit3cb8e9d9e38e4cb9eba2658227b95a8894d4657c (patch)
treee90d2313df3bfbc203d7337d6eab0ba3758887c1
parent1da37bb5a0364781f0237019f35ed597daa03522 (diff)
downloadql-ikiwiki-publish-3cb8e9d9e38e4cb9eba2658227b95a8894d4657c.tar.gz
Change: projgraph to "invert" graph
-rw-r--r--NEWS3
-rwxr-xr-xprojgraph26
2 files changed, 27 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 0345973..0f4cf96 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ NEWS for ql-ikiwiki-publish
Version 0.15+git, not yet released
----------------------------------
+* `projgraph` now creates roadmap graphs where arrows point towards
+ the goal, and automatically finds goal (tasks that nothing depend
+ on).
Version 0.15, released 2018-05-03
----------------------------------
diff --git a/projgraph b/projgraph
index f8ddd70..db17077 100755
--- a/projgraph
+++ b/projgraph
@@ -10,21 +10,24 @@ blocked = 1
finished = 2
ready = 3
next = 4
+goal = 5
statuses = {
'blocked': blocked,
'finished': finished,
'ready': ready,
'next': next,
+ 'goal': goal,
}
def nodeattrs(done):
attrs = {
- unknown: {'shape': 'diamond'},
+ unknown: {'fillcolor': '#ff0000', 'shape': 'diamond'},
blocked: {'fillcolor': '#f4bada', 'shape': 'rectangle'},
finished: {'fillcolor': '#eeeeee'},
ready: {'fillcolor': '#ffffff'},
next: {'fillcolor': '#00cc00'},
+ goal: {'fillcolor': '#00eeee', 'shape': 'diamond'},
}
a = dict(attrs[done])
@@ -63,8 +66,23 @@ def add_missing(tasks):
}
tasks.update(missing)
+def add_parents(tasks):
+ for task in tasks.values():
+ for dep in task.get('depends', []):
+ assert dep in tasks
+ dep = tasks[dep]
+ dep['parents'] = dep.get('parents', []) + [task]
+
+def mark_goals(tasks):
+ for task in tasks.values():
+ if 'status' not in task:
+ if not task.get('parents'):
+ task['status'] = goal
+
def set_status(tasks):
add_missing(tasks)
+ add_parents(tasks)
+ mark_goals(tasks)
tasklist = list(tasks.values())
for task in tasklist:
if 'status' not in task:
@@ -78,6 +96,10 @@ def set_status(tasks):
]
task['depends'] = deps
+# for task in tasklist:
+# print(task['status'], ' '.join(task['label'].split()))
+# sys.exit(0)
+
unknown_tasks = find_unknown(tasklist)
while unknown_tasks:
for t in unknown_tasks:
@@ -106,7 +128,7 @@ for name, task in tasks.items():
status = task['status']
print('{} [{}]'.format(name, nodeattrs(status)))
for dep in task.get('depends', []):
- print('{} -> {}'.format(name, dep))
+ print('{} -> {}'.format(dep, name))
if ikiwiki:
print('"""]]')