def main(): """Perform graph analysis based on input args.""" args = setup_args_parser() graph = load_graph_data(args.graph_file, args.format) libdeps_graph = LibdepsGraph(graph=graph) build_dir = libdeps_graph.graph['build_dir'] if libdeps_graph.graph['graph_schema_version'] == 1: libdeps_graph = networkx.reverse_view(libdeps_graph) analysis = libdeps_analyzer.counter_factory(libdeps_graph, args.counts) for analyzer_args in args.direct_depends: analysis.append( libdeps_analyzer.DirectDependents( libdeps_graph, strip_build_dir(build_dir, analyzer_args))) for analyzer_args in args.common_depends: analysis.append( libdeps_analyzer.CommonDependents( libdeps_graph, strip_build_dirs(build_dir, analyzer_args))) for analyzer_args in args.exclude_depends: analysis.append( libdeps_analyzer.ExcludeDependents( libdeps_graph, strip_build_dirs(build_dir, analyzer_args))) for analyzer_args in args.graph_paths: analysis.append( libdeps_analyzer.GraphPaths( libdeps_graph, strip_build_dir(build_dir, analyzer_args[0]), strip_build_dir(build_dir, analyzer_args[1]))) for analyzer_args in args.critical_edges: analysis.append( libdeps_analyzer.CriticalEdges( libdeps_graph, strip_build_dir(build_dir, analyzer_args[0]), strip_build_dir(build_dir, analyzer_args[1]))) if args.indegree_one: analysis.append(libdeps_analyzer.InDegreeOne(libdeps_graph)) analysis += libdeps_analyzer.linter_factory(libdeps_graph, args.lint) if args.build_data: analysis.append(libdeps_analyzer.BuildDataReport(libdeps_graph)) ga = libdeps_analyzer.LibdepsGraphAnalysis(analysis) if args.format == 'pretty': ga_printer = libdeps_analyzer.GaPrettyPrinter(ga) elif args.format == 'json': ga_printer = libdeps_analyzer.GaJsonPrinter(ga) else: return ga_printer.print()
def main(): """Perform graph analysis based on input args.""" args = setup_args_parser() graph = load_graph_data(args.graph_file, args.format) libdeps_graph = LibdepsGraph(graph=graph) analysis = libdeps_analyzer.counter_factory(libdeps_graph, args.counts) for analyzer_args in args.direct_depends: analysis.append( libdeps_analyzer.DirectDependents(libdeps_graph, analyzer_args)) for analyzer_args in args.common_depends: analysis.append( libdeps_analyzer.CommonDependents(libdeps_graph, analyzer_args)) for analyzer_args in args.exclude_depends: analysis.append( libdeps_analyzer.ExcludeDependents(libdeps_graph, analyzer_args)) for analyzer_args in args.graph_paths: analysis.append( libdeps_analyzer.GraphPaths(libdeps_graph, analyzer_args[0], analyzer_args[1])) for analyzer_args in args.critical_edges: analysis.append( libdeps_analyzer.CriticalEdges(libdeps_graph, analyzer_args[0], analyzer_args[1])) analysis += libdeps_analyzer.linter_factory(libdeps_graph, args.lint) if args.build_data: analysis.append(libdeps_analyzer.BuildDataReport(libdeps_graph)) ga = libdeps_analyzer.LibdepsGraphAnalysis(libdeps_graph=libdeps_graph, analysis=analysis) if args.format == 'pretty': ga_printer = libdeps_analyzer.GaPrettyPrinter(ga) elif args.format == 'json': ga_printer = libdeps_analyzer.GaJsonPrinter(ga) else: return ga_printer.print()