-mode = 0
-
-# Limit drawing the dependency graph to this depth. 0 means 'no limit'.
-max_depth = 0
-
-# Whether to draw the transitive dependencies
-transitive = True
-
-parser = argparse.ArgumentParser(description="Graph packages dependencies")
-parser.add_argument("--check-only", "-C", dest="check_only", action="store_true", default=False,
- help="Only do the dependency checks (circular deps...)")
-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="Limit the dependency graph to DEPTH levels; 0 means no limit.")
-parser.add_argument("--stop-on", "-s", metavar="PACKAGE", dest="stop_list", action="append",
- help="Do not graph past this package (can be given multiple times)." +
- " Can be a package name or a glob, " +
- " 'virtual' to stop on virtual packages, or " +
- "'host' to stop on host packages.")
-parser.add_argument("--exclude", "-x", metavar="PACKAGE", dest="exclude_list", action="append",
- help="Like --stop-on, but do not add PACKAGE to the graph.")
-parser.add_argument("--colours", "-c", metavar="COLOR_LIST", dest="colours",
- default="lightblue,grey,gainsboro",
- help="Comma-separated list of the three colours to use" +
- " to draw the top-level package, the target" +
- " packages, and the host packages, in this order." +
- " Defaults to: 'lightblue,grey,gainsboro'")
-parser.add_argument("--transitive", dest="transitive", action='store_true',
- default=False)
-parser.add_argument("--no-transitive", dest="transitive", action='store_false',
- help="Draw (do not draw) transitive dependencies")
-parser.add_argument("--direct", dest="direct", action='store_true', default=True,
- help="Draw direct dependencies (the default)")
-parser.add_argument("--reverse", dest="direct", action='store_false',
- help="Draw reverse dependencies")
-args = parser.parse_args()
-
-check_only = args.check_only
-
-if args.outfile is None:
- outfile = sys.stdout
-else:
- if check_only:
- sys.stderr.write("don't specify outfile and check-only at the same time\n")
- sys.exit(1)
- outfile = open(args.outfile, "w")
-
-if args.package is None:
- mode = MODE_FULL
-else:
- mode = MODE_PKG
- rootpkg = args.package
-
-max_depth = args.depth
-
-if args.stop_list is None:
- stop_list = []
-else:
- stop_list = args.stop_list
-
-if args.exclude_list is None:
- exclude_list = []
-else:
- exclude_list = args.exclude_list
-
-transitive = args.transitive
-
-if args.direct:
- get_depends_func = brpkgutil.get_depends
- arrow_dir = "forward"
-else:
- if mode == MODE_FULL:
- sys.stderr.write("--reverse needs a package\n")
- sys.exit(1)
- get_depends_func = brpkgutil.get_rdepends
- arrow_dir = "back"
-
-# Get the colours: we need exactly three colours,
-# so no need not split more than 4
-# We'll let 'dot' validate the colours...
-colours = args.colours.split(',', 4)
-if len(colours) != 3:
- sys.stderr.write("Error: incorrect colour list '%s'\n" % args.colours)
- sys.exit(1)
-root_colour = colours[0]
-target_colour = colours[1]
-host_colour = colours[2]