transitive = True
parser = argparse.ArgumentParser(description="Graph packages dependencies")
+parser.add_argument("--outfile", "-o", metavar="OUT_FILE", dest="outfile",
+ help="File in which to generate the dot representation")
parser.add_argument("--package", '-p', metavar="PACKAGE",
help="Graph the dependencies of PACKAGE")
parser.add_argument("--depth", '-d', metavar="DEPTH", dest="depth", type=int, default=0,
help="Draw (do not draw) transitive dependencies")
args = parser.parse_args()
+if args.outfile is None:
+ outfile = sys.stdout
+else:
+ outfile = open(args.outfile, "wb")
+
if args.package is None:
mode = MODE_FULL
else:
color = target_colour
version = dict_version.get(pkg)
if version == "virtual":
- print("%s [label = <<I>%s</I>>]" % (name, label))
+ outfile.write("%s [label = <<I>%s</I>>]\n" % (name, label))
else:
- print("%s [label = \"%s\"]" % (name, label))
- print("%s [color=%s,style=filled]" % (name, color))
+ outfile.write("%s [label = \"%s\"]\n" % (name, label))
+ outfile.write("%s [color=%s,style=filled]\n" % (name, color))
# Print the dependency graph of a package
def print_pkg_deps(depth, pkg):
add = False
break
if add:
- print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
+ outfile.write("%s -> %s\n" % (pkg_node_name(pkg), pkg_node_name(d)))
print_pkg_deps(depth+1, d)
# Start printing the graph data
-print("digraph G {")
+outfile.write("digraph G {\n")
done_deps = []
print_pkg_deps(0, rootpkg)
-print("}")
+outfile.write("}\n")