def retrieve_dependency_graph(specification,
                               exact_match=False,
                               factory=None):
     """
     Gets the best matching generator from a dependency graph generator factory
     and retrieve the dependency from it.
     
     @param specification: A specification 
     @param exact_match: the parameter is passed to the factory.
     @param factory: The dependency graph factory to be used. If None, the dependency graph 
         factory is retrieved from the configuration.
     @type factory: DependencyGraphGeneratorFactory or NoneType
     """
     if factory == None:
         factory = config_dependency_graph_factory
     assert isinstance(factory, DependencyGraphGeneratorFactory)
     assert isinstance(specification, DependencyGraphSpecification)
     generator = IterTools.first(
         factory.get_dependency_graph_generators(specification,
                                                 max_count=1))
     if generator:
         assert isinstance(generator, DependencyGraphGenerator)
         return generator.retrieve_graph()
     else:
         return None
Beispiel #2
0
 def test_first(self):
     testee = (x for x in range(2))
     self.assertEquals(0, IterTools.first(testee))
     self.assertEquals(1, IterTools.first(testee))
     self.assertRaises(StopIteration, IterTools.first, testee)
     self.assertEquals(0, IterTools.first(testee, 0))