diff options
author | Lars Wirzenius <liw@qvarnlabs.com> | 2018-01-26 15:15:46 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@qvarnlabs.com> | 2018-01-26 15:25:38 +0200 |
commit | edb55188bec9c3365687a6ab7f536000c98f8457 (patch) | |
tree | 4ea82ad8be08e4c9ccb9e047e96ef83fa79f45cb /projgraph | |
parent | bcfeb5e8c03e1a6c371a435d6cec821f6a247004 (diff) | |
download | ql-ikiwiki-publish-edb55188bec9c3365687a6ab7f536000c98f8457.tar.gz |
Change: don't require toplevel tasks key, allow missing deps
Diffstat (limited to 'projgraph')
-rwxr-xr-x | projgraph | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -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'])) |