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)
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)
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)