def _toposort_abstractions(package, abstraction_list):
    from vistrails.core.modules.sub_module import find_internal_abstraction_refs
    g = Graph()
    for a in abstraction_list:
        if isinstance(a, tuple):
            if isinstance(a[1], dict) and 'name' in a[1]:
                name = (a[1]['name'], a[1].get('namespace', ''))
            else:
                name = (_parse_abstraction_name(a[0]), '')
            g.add_vertex(name, a)
        else:
            g.add_vertex((_parse_abstraction_name(a), ''), a)
    for a in abstraction_list:
        if isinstance(a, tuple):
            a = a[0]
        for ref in find_internal_abstraction_refs(package, a):
            if ref in g.vertices:
                g.add_edge(ref, a)
    return [g.vertices[v] for v in g.vertices_topological_sort()]

###############################################################################
# ModuleRegistrySignals
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/modules/module_registry.py/_toposort_abstractions/original