Exemple #1
0
 def buildflowgraph(self, func, mute_dot=False):
     """Get the flow graph for a function."""
     if not isinstance(func, types.FunctionType):
         raise TypeError("buildflowgraph() expects a function, "
                         "got %r" % (func,))
     if func in self._prebuilt_graphs:
         graph = self._prebuilt_graphs.pop(func)
     else:
         if self.config.translation.verbose:
             log.start(nice_repr_for_func(func))
         space = FlowObjSpace(self.flowconfig)
         if self.annotator:
             # ZZZ
             self.annotator.policy._adjust_space_config(space)
         elif hasattr(self, 'no_annotator_but_do_imports_immediately'):
             space.do_imports_immediately = (
                 self.no_annotator_but_do_imports_immediately)
         graph = space.build_flow(func)
         if self.config.translation.simplifying:
             simplify.simplify_graph(graph)
         if self.config.translation.list_comprehension_operations:
             simplify.detect_list_comprehension(graph)
         if self.config.translation.verbose:
             log.done(func.__name__)
         elif not mute_dot:
             log.dot()
         self.graphs.append(graph)   # store the graph in our list
     return graph
Exemple #2
0
 def buildflowgraph(self, func, mute_dot=False):
     """Get the flow graph for a function."""
     if not isinstance(func, types.FunctionType):
         raise TypeError("buildflowgraph() expects a function, "
                         "got %r" % (func, ))
     if func in self._prebuilt_graphs:
         graph = self._prebuilt_graphs.pop(func)
     else:
         if self.config.translation.verbose:
             log.start(nice_repr_for_func(func))
         space = FlowObjSpace(self.flowconfig)
         if self.annotator:
             # ZZZ
             self.annotator.policy._adjust_space_config(space)
         elif hasattr(self, 'no_annotator_but_do_imports_immediately'):
             space.do_imports_immediately = (
                 self.no_annotator_but_do_imports_immediately)
         graph = space.build_flow(func)
         if self.config.translation.simplifying:
             simplify.simplify_graph(graph)
         if self.config.translation.list_comprehension_operations:
             simplify.detect_list_comprehension(graph)
         if self.config.translation.verbose:
             log.done(func.__name__)
         elif not mute_dot:
             log.dot()
         self.graphs.append(graph)  # store the graph in our list
     return graph
Exemple #3
0
 def __str__(self):
     if hasattr(self, 'func'):
         return nice_repr_for_func(self.func, self.name)
     else:
         return self.name
Exemple #4
0
 def __str__(self):
     if hasattr(self, 'func'):
         return nice_repr_for_func(self.func, self.name)
     else:
         return self.name