Пример #1
0
    def generate_graphs(self, dep_filter, focus_on_each_group, show):
        full_link_deps_graph = dep_filter.graph()
        link_deps_graph = DependencyFilterHelper.filter_graph(
            dependency_filter_configuration=
            config_dependency_filter_config_class(
                modules=full_link_deps_graph.node_names_iter()),
            graph=full_link_deps_graph)

        decorator_conf = DecoratorSet(
            node_tooltip_decorators=[NodeGroupDecorator()],
            edge_tooltip_decorators=[EdgeGroupDecorator()],
            edge_label_decorators=[SCCEdgeDecorator()])
        basename = self.__generic_files_tools.get_module_link_deps_basename()
        outputter = config_dependency_filter_outputter(decorator_conf)
        description = GraphDescriptionImpl(description=self.BASE_DESCRIPTION,
                                           basename=basename)
        basenames = DependencyFilterOutputterTools.output_detail_and_overview_graph(
            graph=link_deps_graph,
            outputter=outputter,
            description=description)

        # TODO das sollte nur auf dem nicht kollabierten Graphen ausgeführt werden.
        #TODO bei Verwendung des CABDependsParsers ist hier stdout geschlossen... strange
        #self.print_acd(dep_filter.graph())

        if focus_on_each_group:
            PerGroupOutputter.output_focus_on_each_group(
                module_grouper=config_module_grouper_class(
                    modules=full_link_deps_graph.node_names()),
                full_graph=full_link_deps_graph,
                base_name=basename,
                base_description=self.BASE_DESCRIPTION,
                dependency_filter_config_class=
                config_dependency_filter_config_class)
Пример #2
0
    def process(self, node_restriction_in):
        file_include_deps = config_file_include_deps_supply.get_file_include_deps(
        )

        lifter = config_include_link_lifter(
            file_include_deps_supply=config_file_include_deps_supply,
            file_to_module_map_supply=config_file_to_module_map_supply,
            node_restriction_in=node_restriction_in)

        lifter.process(use_mapping_exceptions=True)
        fidp = FileIncludeDepsProcessor(file_include_deps=file_include_deps)
        decorator_config = DecoratorSet(
            edge_tooltip_decorators=(
                ModuleIncludeLinkTargetDetailsDecorator(fidp), ),
            node_tooltip_decorators=(NodeGroupDecorator(), ),
            edge_label_decorators=(SCCEdgeDecorator(), ),
        )
        description = GraphDescriptionImpl(
            description="module-level include dependencies",
            basename=FileModuleIncludeDepsSupply(
            ).get_module_include_deps_basename() + "-impl-except",
            extra="with external dependencies")
        ModuleLinksOutputter.output(module_links=lifter.get_module_links(),
                                    decorator_config=decorator_config,
                                    module_group_conf=config_module_group_conf(
                                        config_module_grouper()),
                                    description=description)
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    Configurator().default()

    if len(sys.argv) == 1:
        print("call: list_module_include_deps_per_target_file TargetModule")
        return
    modulenames = set(sys.argv[1].split(","))

    exceptions = ()
    if "BtcCommonsCore" in modulenames:
        exceptions = set((("stringnumconvint", "hashmap"), ))
    file_to_module_map = config_file_to_module_map_supply.generate_file_to_module_map(
    )
    file_name_mapper = FileNameMapper(file_to_module_map, modulenames)
    generator = FileLevelPseudoModuleDependencyGenerator(
        file_to_module_map=file_to_module_map)
    merged_graph = generator.get_file_level_pseudomodule_graph(
        modulenames=modulenames,
        mapper=file_name_mapper,
        ignore_external=True,
        exceptions=exceptions)
    clustering_processor = MyClusteringProcessor(modulenames)
    clustering_processor.output_clusters()
    cluster_graph = ClusterDependencyLifter(
        file_name_mapper).get_cluster_dependency_graph(
            clustering_result=clustering_processor.get_clustering_result(),
            base_dependency_graph=merged_graph)
    cluster_graph = SCCMerger(cluster_graph).get_scc_merged_graph()
    basename = os.path.join(
        config_basic.get_results_directory(),
        'cluster_graph_for_module-%s' % ("-".join(modulenames), ))
    size_fun = PseudoModuleSizer(
        file_name_mapper,
        path_resolver=FixedBaseDirPathResolver(
            config_basic.get_local_source_base_dir())).module_size
    decorator_config = DecoratorSet(
        node_label_decorators=(
            NodeSizeLabelDecorator(size_func=size_fun),
            NodeGroupDecorator(),
            NodeSizeScalingDecorator(min_render_size=1.5,
                                     max_render_size=8,
                                     size_func=size_fun),
        ),
        edge_label_decorators=(SCCEdgeDecorator(), ),
        node_tooltip_decorators=(),
        edge_tooltip_decorators=())

    description = GraphDescriptionImpl(
        description=
        "file-level pseudomodule cluster graph based on include dependencies",
        basename=basename,
        extra="(%s)" % (", ".join(modulenames), ))
    DependencyFilterOutputter(decorator_config).output(
        filter=None,
        graph=cluster_graph,
        module_group_conf=DefaultNodeGroupingConfiguration(
            node_grouper=NullNodeGrouper()),
        description=description)
    clustering_processor.output_refcounts()
Пример #4
0
    def output_detail_and_overview_graph(
        graph,
        basename=None,
        outputter=None,
        decorator_config=None,
        node_grouper=None,
        module_group_conf=None,
        description=None,
        overview_graph=None,
    ):
        if description == None:
            warnings.warn("Missing description is now deprecated",
                          DeprecationWarning)
            description = GraphDescriptionImpl(basename, "unknown graph")
        else:
            if isinstance(description, basestring):
                warnings.warn("use a GraphDescription as description",
                              DeprecationWarning)
                description = GraphDescriptionImpl(basename=basename,
                                                   description=description)
        if module_group_conf == None:
            if node_grouper == None:
                node_grouper = config_module_grouper()
            module_group_conf = config_module_group_conf(node_grouper)
        if outputter == None:
            outputter = config_dependency_filter_outputter(
                decorator_config=decorator_config)
        else:
            warnings.warn(
                "Passing an outputter is deprecated, just pass decorator_config",
                DeprecationWarning)

        basenames = list()
        basenames.append(description.get_filename())
        group_decorator_set = DecoratorSet(
            edge_tooltip_decorators=[EdgeGroupDecorator()])
        outputter.add_decorators(group_decorator_set)
        outputter.output(graph=graph,
                         module_group_conf=module_group_conf,
                         collapse=False,
                         description=description)
        group_decorator_set = DecoratorSet(
            node_tooltip_decorators=[NodeGroupDecorator()])
        outputter.add_decorators(group_decorator_set)
        description.set_category(description.get_category() + "overview")
        basenames.append(description.get_filename())
        if overview_graph:
            outputter.output(graph=overview_graph,
                             module_group_conf=module_group_conf,
                             collapse=False,
                             description=description)
        else:
            outputter.output(graph=graph,
                             module_group_conf=module_group_conf,
                             collapse=True,
                             description=description)
        return basenames
Пример #5
0
 def __output_combined_graph(self, show_combined_graph, multigraph, multigraph_overview, node_group_conf):
     decorator_conf = DecoratorSet(node_tooltip_decorators=[NodeGroupDecorator()],
                                   edge_tooltip_decorators=[EdgeGroupDecorator(), EPMModuleTypeEdgeDecorator()],
                                   )
     description = self.__get_description()
     # TODO wieso wird hier nicht output_detail_and_overview_graph benutzt?
     #DependencyFilterOutputterTools.output_detail_and_overview_graph(dep_filter.graph(), basename, outputter, module_group_conf)
     node_group_conf.get_node_grouper().configure_nodes(multigraph.node_names())
     config_dependency_filter_outputter(decorator_conf).output_graph \
         (description=description,
          graph_outputter_factory=config_graphical_graph_outputter_factory,
          graph=multigraph,
          node_group_conf=node_group_conf,
          collapse=False)
     description.set_category('overview')
     config_dependency_filter_outputter(decorator_conf).output_graph \
         (description=description,
          graph_outputter_factory=config_graphical_graph_outputter_factory,
          graph=multigraph_overview,
          node_group_conf=node_group_conf,
          collapse=True)
Пример #6
0
    def process(self, show=False):
        self._parser = config_dependency_parser()
        self._parser.process()
        dep_filter = config_dependency_filter(
            config=config_dependency_filter_config)
        self._parser.output(dep_filter)

        decorator_conf = DecoratorSet(
            node_tooltip_decorators=[NodeGroupDecorator()],
            edge_tooltip_decorators=[EdgeGroupDecorator()])
        basename = self.__generic_files_tools.get_module_link_deps_basename(
        ) + '-sub-custom'
        outputter = config_dependency_filter_outputter(decorator_conf)

        graph = dep_filter.graph()
        # TODO Momentan nur ein Test!
        #start_nodes = ['osapi', 'prio4dyn', 'dyn', 'prid4dynmfc', 'bib']
        if config_basic.get_system() == 'prins':
            start_nodes = set(ifilter(is_prins_classic,
                                      graph.node_names())) - set(['osapi'])
            description = GraphDescriptionImpl(
                description=
                "subgraph: modules independent of legacy PRINS (link deps)")
        elif config_basic.get_system() == 'revengtools':
            start_nodes = set(
                ifilter(
                    lambda x: x.startswith(('infrastructure', 'cpp', 'python',
                                            'systems', 'commons.graph')),
                    graph.node_names()))
            description = GraphDescriptionImpl(
                description="subgraph: generic core")
        else:
            raise RuntimeError("Unknown system %s" % config_basic.get_system())
        GraphAlgorithms.remove_subgraph_dependent_on_nodes(graph, start_nodes)

        description.set_basename(basename)
        description.set_section('subgraph')

        DependencyFilterOutputterTools.output_detail_and_overview_graph(
            graph, outputter, description=description)
Пример #7
0
 def __init__(self, colored, types, output_groups, graph, outfile, node_grouper=NullModuleGrouper(), decorator_config=DecoratorSet(node_tooltip_decorators=[NodeGroupDecorator()], edge_tooltip_decorators=[EdgeGroupDecorator()])):
     BaseGraphOutputter.__init__(self, output_groups, graph, outfile, node_grouper, decorator_config, config_generation_log)
     assert isinstance(node_grouper, NullModuleGrouper), "cannot currently handle grouped graph"
     self.__types = types
     self.colored = colored
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.WARNING)
    Configurator().default()

    if len(sys.argv) < 1:
        print(
            "usage: %s <comma-separated list of module names> <comma-separated list of options>"
            % (sys.argv[0]))
        print("valid options:")
        print(
            "  graph: Output a graph (otherwise, only dependency metrics are calculated)"
        )
        print("  external: Include include dependency across module bounds")
        print("  merge: Merge cycles into one node")
        sys.exit(1)

    output_graph = False
    ignore_external = True
    merge_sccs = False

    exceptions = set()
    modulenames = set(sys.argv[1].split(","))
    # TODO !!!
    if "BtcCommonsCore" in modulenames:
        exceptions = set((("stringnumconvint", "hashmap"), ))
        pass

    if len(sys.argv) > 2:
        options = set(sys.argv[2].split(","))
        if 'graph' in options:
            output_graph = True
        if 'external' in options:
            ignore_external = False
        if 'merge' in options:
            merge_sccs = True

    file_to_module_map = config_file_to_module_map_supply.generate_file_to_module_map(
    )
    file_name_mapper = FileNameMapper(file_to_module_map, modulenames)
    generator = FileLevelPseudoModuleDependencyGenerator(
        file_to_module_map=file_to_module_map)
    merged_graph = generator.get_file_level_pseudomodule_graph(
        modulenames=modulenames,
        mapper=file_name_mapper,
        ignore_external=ignore_external,
        exceptions=exceptions)

    logging.debug(merged_graph)
    cdm = ComponentDependencyMetric(merged_graph)
    print("Internal file-level CCD of %s is %i, nCCD=%f, ACD=%f" %
          (", ".join(modulenames), cdm.calculate_ccd(), cdm.calculate_nccd(),
           cdm.calculate_acd()))

    if merge_sccs:
        merger = SCCMerger(merged_graph)
        merged_graph = merger.get_scc_merged_graph()
        if merger.get_sccs_iter():
            print("SCCs:")
            for (i, scc) in enumerate(merger.get_sccs_iter()):
                print("  SCC %i: %s" % (i, ", ".join(scc)))
                print()

    if output_graph:
        node_grouper = config_node_grouper_class()
        node_grouper.configure_nodes(merged_graph.node_names_iter())
        basename = os.path.join(
            config_basic.get_results_directory(),
            'include_links_for_module-%s' % ("-".join(modulenames), ))
        size_fun = PseudoModuleSizer(
            file_name_mapper,
            path_resolver=FixedBaseDirPathResolver(
                config_basic.get_local_source_base_dir())).module_size
        decorator_config = DecoratorSet(
            node_label_decorators=(
                NodeSizeLabelDecorator(size_func=size_fun),
                NodeGroupDecorator(),
                NodeSizeScalingDecorator(min_render_size=1.5,
                                         max_render_size=8,
                                         size_func=size_fun),
            ),
            edge_label_decorators=(SCCEdgeDecorator(), ),
            node_tooltip_decorators=(),
            edge_tooltip_decorators=())

        description = GraphDescriptionImpl(
            description="file-level pseudomodule include dependencies",
            basename=basename,
            extra="(%s->*)" % (", ".join(modulenames), ))
        DependencyFilterOutputter(decorator_config).output(
            filter=None,
            graph=merged_graph,
            module_group_conf=DefaultNodeGroupingConfiguration(
                node_grouper=node_grouper),
            description=description)