Exemple #1
0
 def __init__(self, decorator_config=None, *args, **kwargs):
     if decorator_config == None:
         decorator_config = DecoratorSet()
     decorator_config.add_node_label_decorators \
         ([
           ModuleSizeLabelDecorator(), 
           ModuleSizeScalingDecorator(2, 7, ScalingTypes.RADICAL),
           ModuleColorNodeDecorator(EPMNodeColorer()),
           TerminalNodeDecorator(),
           ])
     DependencyFilterOutputter.__init__(self,
                                        decorator_config=decorator_config, 
                                        *args, **kwargs)
Exemple #2
0
 def __init__(self, decorator_config=None, *args, **kwargs):
     if decorator_config == None:
         decorator_config = DecoratorSet()
     decorator_config.add_graph_decorators(
         [FileRevisionNodeAndGraphDecorator()])
     decorator_config.add_node_label_decorators \
         ([ModuleSizeLabelDecorator(),
           ModuleSizeScalingDecorator(3, 8, ScalingTypes.RADICAL),
           ModuleColorNodeDecorator(config_node_colorer),
           TerminalNodeDecorator(),
           ])
     DependencyFilterOutputter.__init__(self,
                                        decorator_config=decorator_config,
                                        *args,
                                        **kwargs)
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.WARNING)
    Configurator().default()

    from_module = sys.argv[1]
    to_module = sys.argv[2]

    fidp = FileIncludeDepsProcessor()
    graph = fidp.graph_for_modules(from_module, to_module)

    basename = os.path.join(
        config_basic.get_results_directory(),
        'include_links_for_modules-%s-%s' % (from_module, to_module))
    decorator_config = DecoratorSet(
        node_label_decorators=(FilenameURLNodeDecorator(), ),
        edge_label_decorators=(),
        node_tooltip_decorators=(),
        edge_tooltip_decorators=())

    description = GraphDescriptionImpl(
        description="file-level include dependencies",
        basename=basename,
        extra="(%s->%s)" % (from_module, to_module))
    DependencyFilterOutputter(decorator_config).output(
        filter=None,
        graph=graph,
        module_group_conf=DefaultNodeGroupingConfiguration(),
        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()
 def __init__(self, decorator_config=None, base_graph=None, *args, **kwargs):
     if decorator_config == None:
         decorator_config = DecoratorSet()
     decorator_config.add_graph_decorators([FileRevisionNodeAndGraphDecorator()])
     decorator_config.add_node_label_decorators \
         ([ModuleSizeLabelDecorator(),
           #ModuleSizeScalingDecorator(3, 8, ScalingTypes.RADICAL, is_prins_classic),
           ModuleWeightedDepsScalingDecorator(min_render_size=2,
              max_render_size=12,
              scale_type=ScalingTypes.RADICAL,
              base_graph=base_graph),
           ModuleColorNodeDecorator(EPMNodeColorer()),
           TerminalNodeDecorator(),
           ])
     DependencyFilterOutputter.__init__(self,
                                        decorator_config=decorator_config,
                                        base_graph=base_graph,
                                        *args, **kwargs)
def main():
    logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
    Configurator().default()

    module_name = 'BtcCommonsCore'
    restrict_to_headers = False

    file_to_module_map = config_file_to_module_map_supply.generate_file_to_module_map(
        False)
    all_file_links = config_file_include_deps_supply.get_file_include_deps()
    module_file_links = (AttributedEdge(from_node=from_file, to_node=to_file)
                         for (from_file, to_file) in all_file_links
                         if from_file in file_to_module_map and \
                         VirtualModuleTypes.remove_suffixes(file_to_module_map[from_file]) == module_name and \
                         (not restrict_to_headers or from_file.endswith('.h')))
    #pprint(list(module_file_links))
    # TODO is this correct? does the output graph contain anything if the module list is empty?
    dependency_filter = DefaultDependencyFilter(
        config=MyDependencyFilterConfiguration(), module_list=())
    #module_list=set(edge.get_from_node() for edge in module_file_links))
    graph = DependencyFilterHelper.filter_graph(
        dependency_filter=dependency_filter,
        graph=AttributeGraph(edges=module_file_links))

    decorator_config = DecoratorSet(
        edge_label_decorators=[SCCEdgeDecorator()],
        node_label_decorators=[
            NodeSizeLabelDecorator(size_func=FileSizer.get_file_size),
            NodeSizeScalingDecorator(size_func=FileSizer.get_file_size,
                                     min_render_size=3,
                                     max_render_size=14,
                                     scale_type=ScalingTypes.RADICAL),
            ModuleColorNodeDecorator(EPMNodeColorer()),
        ])
    graph_description = GraphDescriptionImpl(
        description="internal include dependencies of %s" % module_name,
        basename=os.path.join(config_basic.get_results_directory(),
                              module_name),
        section='module-internal')
    DependencyFilterOutputterTools.output_detail_and_overview_graph(
        graph=graph,
        #decorator_config=decorator_config,
        description=graph_description,
        outputter=DependencyFilterOutputter(decorator_config=decorator_config),
        module_group_conf=MyNodeGroupingConfiguration(MyNodeGrouper()))
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)