Remove tasks not in tasklist from dependency graph

Use filter() for filtering instead of list comprehensions
This commit is contained in:
Anders Ingemann 2013-06-27 20:59:22 +02:00
parent 237dde9285
commit 29394270c6

View file

@ -38,11 +38,12 @@ class TaskList(object):
from common.phases import order from common.phases import order
graph = {} graph = {}
for task in tasks: for task in tasks:
graph[task] = [] successors = []
graph[task].extend([self.get(succ) for succ in task.before]) successors.extend([self.get(succ) for succ in task.before])
graph[task].extend([succ for succ in tasks if type(task) in succ.after]) successors.extend(filter(lambda succ: type(task) in succ.after, tasks))
succeeding_phases = order[order.index(task.phase)+1:] 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) components = self.strongly_connected_components(graph)
cycles_found = 0 cycles_found = 0