Print out a neat targets dependency tree based on requested targets.

    Use graphviz to render the dot file, e.g.:

    > ybt dot :foo :bar | dot -Tpng -o graph.png
772701
def cmd_dot(conf: Config):
    
    build_context = BuildContext(conf)
    populate_targets_graph(build_context, conf)
    if conf.output_dot_file is None:
        write_dot(build_context, conf, sys.stdout)
    else:
        with open(conf.output_dot_file, 'w') as out_file:
            write_dot(build_context, conf, out_file)
1277520
def make_dep_graph(depender):
	
	shutit_global.shutit_global_object.yield_to_draw()
	digraph = ''
	for dependee_id in depender.depends_on:
		digraph = (digraph + '"' + depender.module_id + '"->"' + dependee_id + '";\n')
	return digraph
146891
def show(self):
        
        self.data()
        print("")
        self.msg.template(78)
        print("| {0}{1}{2}".format("Dependencies", " " * 20, "Packages"))
        self.msg.template(78)
        for key, value in self.dmap.iteritems():
            print("  {0}{1}{2}{3}{4}".format(
                self.green, key, self.endc, " " * (32-len(key)),
                ", ".join(value)))
        self.summary()
        if self.image:
            Graph(self.image).dependencies(self.dmap)
417703
def main(args=None):
    
    parser = get_parser()
    args = parser.parse_args(args=args)

    if not (args.matrix or args.dependencies or args.treemap or args.graph):
        args.matrix = True

    # split comma-separated args
    packages = []
    for arg in args.packages:
        if ',' in arg:
            for package in arg.split(','):
                if package not in packages:
                    packages.append(package)
        elif arg not in packages:
            packages.append(arg)

    # guess convenient depth
    depth = args.depth
    if depth is None:
        depth = guess_depth(packages)

    # open file if not stdout
    output = args.output
    if isinstance(output, str):
        output = open(output, 'w')

    dsm = DSM(*packages, build_tree=True, build_dependencies=True,
              enforce_init=not args.greedy)

    if dsm.empty:
        return 1

    indent = args.indent
    if indent is None:
        if args.format == CSV:
            indent = 0
        else:
            indent = 2
    elif indent < 0 and args.format == JSON:
        # special case for json.dumps indent argument
        indent = None

    try:
        if args.dependencies:
            dsm.print(format=args.format, output=output, indent=indent)
        elif args.matrix:
            dsm.print_matrix(format=args.format, output=output,
                             depth=depth, indent=indent)
        elif args.treemap:
            dsm.print_treemap(format=args.format, output=output)
        elif args.graph:
            dsm.print_graph(format=args.format, output=output,
                            depth=depth, indent=indent)
    except BrokenPipeError:
        # avoid traceback
        return 2

    return 0
755594
def output(self, filename):
        

        if not filename.endswith('.dot'):
            filename += '.dot'
        if filename == ".dot":
            filename = "all_contracts.dot"

        with open(filename, 'w', encoding='utf8') as f:
            self.info(f'Call Graph: {filename}')
            f.write('\n'.join(['strict digraph {'] + [self._process_functions(self.slither.functions)] +  ['}']))


        for derived_contract in self.slither.contracts_derived:
            with open(f'{derived_contract.name}.dot', 'w', encoding='utf8') as f:
                self.info(f'Call Graph: {derived_contract.name}.dot')
                f.write('\n'.join(['strict digraph {'] + [self._process_functions(derived_contract.functions)] +  ['}']))
7420
function buildDependencyGraph(module, dependencies, graph) {
	if (module && !graph[module]) {
		graph[module] = [];
	}

	var dependencyNames = Object.keys(dependencies);
	dependencyNames.forEach(function(dependencyName) {
		var dependency = dependencies[dependencyName];

		if (module && graph[module].indexOf(dependencyName) === -1) {
			graph[module].push(dependencyName);
		}

		// Traverse down to this dependency dependencies:
		// Dependency-ception.
		if (dependency.dependencies) {
			buildDependencyGraph(dependencyName, dependency.dependencies, graph);
		}
	});
}
1116991
def dependencies_graph(nodes=nil)
      nodes = @resolver.getDependenciesGraph() unless nodes

      graph = {}
      if Naether.platform == 'java'
        nodes.each do |k,v|
          deps = dependencies_graph(v)
          graph[k] = Naether::Java.convert_to_ruby_hash( deps )
        end
      else
        iterator = nodes.entrySet().iterator();
        while iterator.hasNext()
          entry = iterator.next()
          deps = dependencies_graph(entry.getValue())
          graph[entry.getKey().toString()] = Naether::Java.convert_to_ruby_hash( deps )
        end
      end

      graph
    end
580384
def generate_dep_names(self, target: Target):
        """"""
        yield from sorted(get_descendants(self.target_graph, target.name))
129982
public static void print(Collection<TypedDependency> dependencies, PrintWriter pw) {
    pw.println(toString(dependencies, false));
  }
160682
def _output_dependency_tree(self, target):
    """"""

    def make_line(dep, indent, is_dupe=False):
      indent_join, indent_chars = ('--', '  |') if self.should_tree else ('', '  ')
      dupe_char = '*' if is_dupe else ''
      return ''.join((indent * indent_chars, indent_join, dupe_char, dep))

    def output_deps(dep, indent, outputted, stack):
      dep_id, internal = self._dep_id(dep)

      if self.is_minimal and dep_id in outputted:
        return

      if self.output_candidate(internal):
        yield make_line(dep_id,
                        0 if self.is_external_only else indent,
                        is_dupe=dep_id in outputted)
        outputted.add(dep_id)

      for sub_dep in self._enumerate_visible_deps(dep, self.output_candidate):
        for item in output_deps(sub_dep, indent + 1, outputted, stack + [(dep_id, indent)]):
          yield item

    for item in output_deps(target, 0, set(), []):
      yield item
31952
def print_dot_chart(self):
        """"""
        print("digraph toil_graph {")
        print("# This graph was created from job-store: %s" % self.jobStoreName)

        # Make job IDs to node names map
        jobsToNodeNames = dict(enumerate(map(lambda job: job.jobStoreID, self.jobsToReport)))

        # Print the nodes
        for job in set(self.jobsToReport):
            print('%s [label="%s %s"];' % (
                jobsToNodeNames[job.jobStoreID], job.jobName, job.jobStoreID))

        # Print the edges
        for job in set(self.jobsToReport):
            for level, jobList  in enumerate(job.stack):
                for childJob in jobList:
                    # Check, b/c successor may be finished / not in the set of jobs
                    if childJob.jobStoreID in jobsToNodeNames:
                        print('%s -> %s [label="%i"];' % (
                            jobsToNodeNames[job.jobStoreID],
                            jobsToNodeNames[childJob.jobStoreID], level))
        print("}")
223845
def output_tree(self, t, seen):
        """"""
        if not t:
            return
        for c in t.children:
            self.output_tree(c, seen)
        if t.name in seen:
            return
        seen[t.name] = True
        if t.resource_name:
            output_class(t.name, t.props, self.override, t.resource_name)
        else:
            output_class(t.name, t.props, self.override)
689400
def latex_visit_inheritance_diagram(self, node):
    # type: (nodes.NodeVisitor, inheritance_diagram) -> None
    
    graph = node['graph']

    graph_hash = get_graph_hash(node)
    name = 'inheritance%s' % graph_hash

    dotcode = graph.generate_dot(name, env=self.builder.env,
                                 graph_attrs={'size': '"6.0,6.0"'})
    render_dot_latex(self, node, dotcode, {}, 'inheritance')
    raise nodes.SkipNode
1020629
def output_files(self):
        """"""
        for dep in self.subgraph.successors(self.address):
            dep_rule = self.subgraph.node[dep]['target_obj']
            for out_file in dep_rule.output_files:
                yield out_file
433214
def graphviz(self, highlight=None, maximal_label=None, topdown=None,
            filename=None, directory=None, render=False, view=False):
        """"""
        return visualize.featuresystem(self, highlight, maximal_label,
            topdown, filename, directory, render, view)
463305
private static void printTargetPathList(FileStatus[] targetTmpFiles)
    {
        StringBuilder builder = new StringBuilder();
        builder.append("Preprocess target files:");
        String lineSeparator = System.getProperty("line.separator");

        for (FileStatus targetFile : targetTmpFiles)
        {
            builder.append(targetFile.getPath() + lineSeparator);
        }

        logger.info(builder.toString());
    }
172517
def dot_format(out, graph, name="digraph"):
    """"""

    out.write("digraph %s {\n" % name)
    for step, deps in each_step(graph):
        for dep in deps:
            out.write("  \"%s\" -> \"%s\";\n" % (step, dep))

    out.write("}\n")