summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@qvarnlabs.com>2018-01-26 15:15:46 +0200
committerLars Wirzenius <liw@qvarnlabs.com>2018-01-26 15:25:38 +0200
commitedb55188bec9c3365687a6ab7f536000c98f8457 (patch)
tree4ea82ad8be08e4c9ccb9e047e96ef83fa79f45cb
parentbcfeb5e8c03e1a6c371a435d6cec821f6a247004 (diff)
downloadql-ikiwiki-publish-edb55188bec9c3365687a6ab7f536000c98f8457.tar.gz
Change: don't require toplevel tasks key, allow missing deps
-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']))