def main(): graphviz = GraphvizOutput() pycallgraph = PyCallGraph( output=graphviz, config=Config(include_stdlib=True) ) pycallgraph.start() import HTMLParser # noqa pycallgraph.stop() # Set the edge colour to black for all examples graphviz.edge_color_func = lambda e: Color(0, 0, 0) # Default node colouring graphviz.output_file = 'colours-default.png' graphviz.done() def run(func, output_file): graphviz.node_color_func = func graphviz.output_file = output_file graphviz.done() run(rainbow, 'colors-rainbow.png') run(greyscale, 'colors-greyscale.png') run(orange_green, 'colors-orange-green.png') run(rand, 'colors-random.png')
def main(): graphviz = GraphvizOutput() pycallgraph = PyCallGraph(output=graphviz, config=Config(include_stdlib=True)) pycallgraph.start() from html.parser import HTMLParser # noqa pycallgraph.stop() # Set the edge colour to black for all examples graphviz.edge_color_func = lambda e: Color(0, 0, 0) # Default node colouring graphviz.output_file = "colours-default.png" graphviz.done() def run(func, output_file): graphviz.node_color_func = func graphviz.output_file = output_file graphviz.done() run(rainbow, "colors-rainbow.png") run(greyscale, "colors-greyscale.png") run(orange_green, "colors-orange-green.png") run(rand, "colors-random.png")
class PyCallgraphProvider(CallgraphProviderBase): def __init__(self, configuration: CallgraphConfiguration, caller_name: str = None): super().__init__(configuration, caller_name) self._config = Config() self._config.trace_filter = GlobbingFilter(exclude=[ 'pycallgraph.*' 'excallgraph', 'excallgraph.*', 'providers.*' ]) if self._configuration.excludes is not None: self._config.trace_filter.exclude += self._configuration.excludes if self._configuration.includes is not None: self._config.trace_filter.include = self._configuration.includes def __enter__(self): self._provider = PyCallGraph(output=GraphvizOutput( output_file=path.join( self._path, f"{self._caller_name}.{self._configuration.format}"), output_format=self._configuration.format), config=self._config) return self def __exit__(self, exc_type, exc_val, exc_tb): if self._provider is not None: self._provider.stop() return self._provider.__exit__(exc_type, exc_val, exc_tb) def start(self): '''Starts Capturing Trace''' return self._provider.start() def stop(self): '''Stop Capture Trace''' return self._provider.stop() def get_path(self): return self._configuration.path def get_format(self): return self._configuration.format def create_path_if_not_exists(self): try: makedirs(self.get_path()) except OSError as ex: if ex.errno == errno.EEXIST and os.path.isdir(self.get_path()): pass else: raise