summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-12-02 23:17:16 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-12-02 23:17:16 +0000
commitc89b8408c0115e9fccdd4bfe180e93eb746b12cd (patch)
tree3f706c5fe4e3d456cbfe24ebd18063820c28446e /doc
parent1aff3d1820f8efe90d811d96c0f5b3806f20d325 (diff)
downloadpython-apt-c89b8408c0115e9fccdd4bfe180e93eb746b12cd.tar.gz
* added "{candidate,installed}Downloadable"
Diffstat (limited to 'doc')
-rw-r--r--doc/examples/dependant-pkgs.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py
new file mode 100644
index 00000000..656e38bf
--- /dev/null
+++ b/doc/examples/dependant-pkgs.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+import apt
+import sys
+
+pkgs = set()
+cache = apt.Cache()
+for pkg in cache:
+ candver = cache._depcache.GetCandidateVer(pkg._pkg)
+ if candver == None:
+ continue
+ dependslist = candver.DependsList
+ for dep in dependslist.keys():
+ # get the list of each dependency object
+ for depVerList in dependslist[dep]:
+ for z in depVerList:
+ # get all TargetVersions of
+ # the dependency object
+ for tpkg in z.AllTargets():
+ if sys.argv[1] == tpkg.ParentPkg.Name:
+ pkgs.add(pkg.name)
+
+main = []
+universe = []
+for pkg in pkgs:
+ if "universe" in cache[pkg].section:
+ universe.append(cache[pkg].sourcePackageName)
+ else:
+ main.append(cache[pkg].sourcePackageName)
+
+print "main:"
+print "\n".join(main)
+print
+
+print "universe:"
+print "\n".join(universe)