summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rwxr-xr-xprojgraph20
2 files changed, 22 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 22a4702..19ebec9 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ NEWS for ql-ikiwiki-publish
Version 0.12+git, not yet released
----------------------------------
+* `projgraph` no longer requires a top-level `tasks` key, but still
+ accepts it. Also, it doesn't crash a depended-on task doesn't exist,
+ but adds them with a suitable label so they are noticed.
Version 0.12, released 2018-01-10
----------------------------------
diff --git a/projgraph b/projgraph
index c3f5757..1a9813e 100755
--- a/projgraph
+++ b/projgraph
@@ -53,13 +53,31 @@ def any_dep(tasks, task, status):
return False
+def add_missing(tasks):
+ missing = {}
+ for task in tasks.values():
+ for dep in task.get('depends', []):
+ if dep not in tasks:
+ missing[dep] = {
+ 'label': '{} IS MISSING'.format(dep),
+ }
+ tasks.update(missing)
+
def set_status(tasks):
+ add_missing(tasks)
tasklist = list(tasks.values())
for task in tasklist:
if 'status' not in task:
task['status'] = unknown
else:
task['status'] = statuses[task['status']]
+ deps = [
+ dep
+ for dep in task.get('depends', [])
+ if dep in tasks
+ ]
+ task['depends'] = deps
+
unknown_tasks = find_unknown(tasklist)
while unknown_tasks:
for t in unknown_tasks:
@@ -81,7 +99,7 @@ if ikiwiki:
else:
print('digraph "project" {')
-tasks = obj['tasks']
+tasks = obj.get('tasks', obj)
set_status(tasks)
for name, task in tasks.items():
print('{} [label="{}"]'.format(name, task['label']))