Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Yield a topological sort of the given list of engines.

:type engines: list
:param engines: Unsorted instances of :class:`StorageEngine`.

        def sort_engines(engines):
    """Yield a topological sort of the given list of engines.

    :type engines: list
    :param engines: Unsorted instances of :class:`StorageEngine`.

    # Partial ordering of engine classes, keys come before values.
    edges = defaultdict(set)

    # Collection of engine instances grouped by their class.
    engine_objs = defaultdict(set)

    # Find all edges between registered engine classes
    for engine in engines:
        engine_cls = engine.__class__
        for edge_cls in engine.try_before:
            for edge_cls_implementation in edge_cls:
        for edge_cls in engine.try_after:
            for edge_cls_implementation in edge_cls:

    # Iterate over the engine classes
    todo = set(engine_objs.iterkeys())
    while todo:
        # Pull out classes that have no unsatisfied edges
        output = set()
        for engine_cls in todo:
            if not todo.intersection(edges[engine_cls]):
        if not output:
            raise RuntimeError('Circular dependency detected.')

        # Collect all the engine instances we'll be returning in this round,
        # ordering them by ID to give consistent results each time we run this.
        output_instances = []
        for engine_cls in output:

        for engine in output_instances:
            yield engine

src/m/e/mediadrop-HEAD/mediadrop/controllers/admin/storage.py   mediadrop(Download)
from mediadrop.lib.decorators import autocommit, expose, observable, validate
from mediadrop.lib.helpers import redirect, url_for
from mediadrop.lib.storage import sort_engines, StorageEngine
from mediadrop.model import DBSession, fetch_row
from mediadrop.plugin import events
        engines = list(sort_engines(engines))
        existing_types = set(ecls.engine_type for ecls in engines)
        addable_engines = [