Exemplo n.º 1
0
 def get_config_variables_iter(cls, modules):
     """
     Returns a list of pairs of a module and a name of a configuration variables in that module. 
     """
     config_variable_iter = compatchain.from_iterable(((module, config_var_name)
                              for config_var_name in cls.get_config_variables_single(module))
                             for module in modules)
     return config_variable_iter
Exemplo n.º 2
0
 def union_all(iterables):
     """
     >>> sorted(CollectionTools.union_all([[1, 2], [2, 3]]))
     [1, 2, 3]
     >>> sorted(CollectionTools.union_all([(1, 2), (2, 3)]))
     [1, 2, 3]
     >>> sorted(CollectionTools.union_all([((1, 2), (2, 3),)]))
     [(1, 2), (2, 3)]
     """
     #        result = set()
     #        for iterable in iterables:
     #            result.update(iterable)
     #
     #        return result
     # TODO ist das effizienter als
     return set(compatchain.from_iterable(iterables))
Exemplo n.º 3
0
 def transpose(inDictionary):
     """
     Converts a A-to-set(B)-valued-dictionary to a B-to-set(A)-dictionary.
     
     @rtype: defaultdict(set)
     
     >>> pprint.pprint(dict(SetValuedDictTools.transpose({'x': set(['a', 'b']), 'y': set(['c'])})))
     {'a': set(['x']), 'b': set(['x']), 'c': set(['y'])}
     """
     allValues = set(compatchain.from_iterable(inDictionary.itervalues()))
     transposedDictionary = defaultdict(set)
     for value in allValues:
         #transposedDictionary.update({value: set()})
         for key in inDictionary:
             if value in inDictionary[key]:
                 transposedDictionary[value].add(key)
     return transposedDictionary
Exemplo n.º 4
0
 def get_scc_node_name(self, scc):
     return "_".join(sorted(compatchain.from_iterable(x.split("_") for x in scc)))
Exemplo n.º 5
0
 def edge_iter(self):
     return compatchain.from_iterable(graph.edges() for graph in self.__graphs)
Exemplo n.º 6
0
 def edges(self):
     # TODO Man darf aus dem Ergebnis aber keine Menge bilden!!
     if self.__edges == None:
         self.__edges = tuple(compatchain.from_iterable(graph.edges()
                                                  for graph in self.__graphs))
     return self.__edges
Exemplo n.º 7
0
 def concat_all(iterables):
     """
     >>> CollectionTools.concat_all([[1, 2], [2, 3]])
     [1, 2, 2, 3]
     """
     return list(compatchain.from_iterable(iterables))