예제 #1
0
파일: main.py 프로젝트: starcraftman/pakit
def order_tasks(recipe_names, task_class):
    """
    Order the recipes so that all dependencies can be met.

    Args:
        recipe_names: List of recipe names.
        task_class: The Task to be carried out on the recipes.

    Returns:
        A list of task_class instances ordered to meet dependencies.

    Raises:
        CycleInGraphError: The dependencies could not be resolved
        as there was a cycle in the dependency graph.
    """
    graph = DiGraph()

    for recipe_name in recipe_names:
        add_deps_for(recipe_name, graph)

    return [task_class(recipe_name) for recipe_name in topological_sort(graph)]
예제 #2
0
파일: test_graph.py 프로젝트: kostyll/pakit
 def test_topological_sort(self):
     print(self.graph)
     top_list = list(topological_sort(self.graph))
     assert len(top_list) == 8
     assert self.graph.size == 0