From 29394270c67bfd69995a5dfd5da537799394b954 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Thu, 27 Jun 2013 20:59:22 +0200 Subject: [PATCH] Remove tasks not in tasklist from dependency graph Use filter() for filtering instead of list comprehensions --- base/tasklist.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/base/tasklist.py b/base/tasklist.py index 0ffbf51..b16dffc 100644 --- a/base/tasklist.py +++ b/base/tasklist.py @@ -38,11 +38,12 @@ class TaskList(object): from common.phases import order graph = {} for task in tasks: - graph[task] = [] - graph[task].extend([self.get(succ) for succ in task.before]) - graph[task].extend([succ for succ in tasks if type(task) in succ.after]) + successors = [] + successors.extend([self.get(succ) for succ in task.before]) + successors.extend(filter(lambda succ: type(task) in succ.after, tasks)) succeeding_phases = order[order.index(task.phase)+1:] - graph[task].extend([succ for succ in tasks if succ.phase in succeeding_phases]) + successors.extend(filter(lambda succ: succ.phase in succeeding_phases, tasks)) + graph[task] = filter(lambda succ: succ in self.tasks, successors) components = self.strongly_connected_components(graph) cycles_found = 0