def order_components(self): components_byname = {component.name: component for component in self.component_plugins} G_prefilter = {name: component.component_dependencies for name, component in components_byname.iteritems()} G_postfilter = {} for name, deps in G_prefilter.iteritems(): # FIXME: log warning [that's why this isn't a dict comprehension] if any(dep not in components_byname for dep in deps): continue G_postfilter[name] = deps self.component_plugins = [components_byname[name] for name in utils.topsort(G_postfilter)]
def test_manycycle(self): with self.assertRaises(utils.CircularDependencyError): list(utils.topsort({0: [], 1: [0], 2: [3], 3: [2]}))
def test_many(self): self.assertEqual( list(utils.topsort({0: [], 1: [0], 2: [1], 3: [1, 2]})), [0, 1, 2, 3])
def test_singlecycle(self): with self.assertRaises(utils.CircularDependencyError): list(utils.topsort({1: [1]}))
def test_single(self): self.assertEqual( list(utils.topsort({1: []})), [1])
def test_empty(self): self.assertEqual( list(utils.topsort({})), [])
def init_postprocessors(self): postprocessors = self.engine.plugins.produce_instances( MutatingPostProcessingPlugin) self.postprocessors = list(utils.topsort( {p: p.processing_dependencies for p in postprocessors}))