Esempio n. 1
0
    def _sort_methods(self, methods):
        methods = dict((method.__name__, method) for method in methods)
        graph = {}

        for method in methods.itervalues():
            edges = set()
            for name in method.after:
                if name in methods:
                    edges.add(methods[name])
            graph[method] = edges

        return topological_sort(graph)
Esempio n. 2
0
    def _sort_methods(self, candidates):
        methods = {}
        for method in candidates:
            if method.service is None:
                methods[method.__name__] = method

        graph = {}
        for method in methods.itervalues():
            edges = set()
            for name in method.after:
                if name in methods:
                    edges.add(methods[name])
            graph[method] = edges

        return topological_sort(graph)
Esempio n. 3
0
    def _enumerate_services(self, session):
        graph = {}
        query = session.query(Service)

        for service in list(query):
            graph[service] = set()
            if service.dependencies:
                for id in service.dependencies:
                    dependency = query.get(id)
                    if dependency:
                        graph[service].add(dependency)
                    else:
                        raise InvalidDependencyError(id)

        return topological_sort(graph)
Esempio n. 4
0
    def _sort_methods(self, candidates):
        methods = {}
        for method in candidates:
            if method.service is None:
                methods[method.__name__] = method

        graph = {}
        for method in methods.itervalues():
            edges = set()
            for name in method.after:
                if name in methods:
                    edges.add(methods[name])
            graph[method] = edges

        return topological_sort(graph)
Esempio n. 5
0
    def _enumerate_services(self, session):
        graph = {}
        query = session.query(Service)

        for service in list(query):
            graph[service] = set()
            if service.dependencies:
                for id in service.dependencies:
                    dependency = query.get(id)
                    if dependency:
                        graph[service].add(dependency)
                    else:
                        raise InvalidDependencyError(id)

        return topological_sort(graph)