cli/graph: Add option to generate reverse dependency graph
This commit is contained in:
+17
-8
@@ -612,7 +612,7 @@ def get_package_requirements(packages):
|
|||||||
|
|
||||||
# ****** Danger Zone Below! Tressspassers' eyes will explode! ********** #
|
# ****** Danger Zone Below! Tressspassers' eyes will explode! ********** #
|
||||||
|
|
||||||
def package_graph(A, packagedb, ignore_installed = False):
|
def package_graph(A, packagedb, ignore_installed = False, reverse=False):
|
||||||
"""Construct a package relations graph.
|
"""Construct a package relations graph.
|
||||||
|
|
||||||
Graph will contain all dependencies of packages A, if ignore_installed
|
Graph will contain all dependencies of packages A, if ignore_installed
|
||||||
@@ -638,13 +638,22 @@ def package_graph(A, packagedb, ignore_installed = False):
|
|||||||
for x in B:
|
for x in B:
|
||||||
pkg = packagedb.get_package(x)
|
pkg = packagedb.get_package(x)
|
||||||
#print pkg
|
#print pkg
|
||||||
for dep in pkg.runtimeDependencies():
|
if reverse:
|
||||||
if ignore_installed:
|
for name,dep in packagedb.get_rev_deps(x):
|
||||||
if dep.satisfied_by_installed():
|
if ignore_installed:
|
||||||
continue
|
if dep.satisfied_by_installed():
|
||||||
if not dep.package in G_f.vertices():
|
continue
|
||||||
Bp.add(str(dep.package))
|
if not name in G_f.vertices():
|
||||||
G_f.add_dep(x, dep)
|
Bp.add(name)
|
||||||
|
G_f.add_dep(name, dep)
|
||||||
|
else:
|
||||||
|
for dep in pkg.runtimeDependencies():
|
||||||
|
if ignore_installed:
|
||||||
|
if dep.satisfied_by_installed():
|
||||||
|
continue
|
||||||
|
if not dep.package in G_f.vertices():
|
||||||
|
Bp.add(str(dep.package))
|
||||||
|
G_f.add_dep(x, dep)
|
||||||
B = Bp
|
B = Bp
|
||||||
return G_f
|
return G_f
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -51,6 +51,9 @@ the package in graphviz format to 'pgraph.dot'.
|
|||||||
group.add_option("--ignore-installed", action="store_true",
|
group.add_option("--ignore-installed", action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
help=_("Do not show installed packages"))
|
help=_("Do not show installed packages"))
|
||||||
|
group.add_option("-R", "--reverse", action="store_true",
|
||||||
|
default=False,
|
||||||
|
help=_("Draw reverse dependency graph"))
|
||||||
group.add_option("-o", "--output", action="store",
|
group.add_option("-o", "--output", action="store",
|
||||||
default='pgraph.dot',
|
default='pgraph.dot',
|
||||||
help=_("Dot output file"))
|
help=_("Dot output file"))
|
||||||
@@ -88,5 +91,5 @@ the package in graphviz format to 'pgraph.dot'.
|
|||||||
a = pisi.api.list_installed()
|
a = pisi.api.list_installed()
|
||||||
|
|
||||||
g = pisi.api.package_graph(a, packagedb,
|
g = pisi.api.package_graph(a, packagedb,
|
||||||
ignore_installed = ctx.get_option('ignore_installed'))
|
ignore_installed = ctx.get_option('ignore_installed'), reverse = ctx.get_option('reverse'))
|
||||||
g.write_graphviz(file(ctx.get_option('output'), 'w'))
|
g.write_graphviz(file(ctx.get_option('output'), 'w'))
|
||||||
|
|||||||
Reference in New Issue
Block a user