def getToposortedPlugins(plugins, curConfig=None, ignoreMissing=False):
    """
    Given a set of plugins to load, construct the full DAG of required plugins
    to load and yields them in toposorted order.
    """
    curConfig = curConfig or _config.getConfig()
    plugins = set(plugins)

    allPlugins = findAllPlugins(curConfig)
    dag = {}
    visited = set()

    def addDeps(plugin):
        if plugin not in allPlugins:
            message = 'Required plugin %s does not exist.' % plugin
            if ignoreMissing:
                print(TerminalColor.error(message))
                girder.logger.error(message)
                return
            else:
                raise ValidationException(message)

        deps = allPlugins[plugin]['dependencies']
        dag[plugin] = deps

        for dep in deps:
            if dep in visited:
                return
            visited.add(dep)
            addDeps(dep)

    for plugin in plugins:
        addDeps(plugin)

    for pset in toposort(dag):
        for plugin in pset:
            yield plugin
dataset/ETHPy150Open girder/girder/girder/utility/plugin_utilities.py/getToposortedPlugins/original