summaryrefslogtreecommitdiffstats
path: root/doc/examples/dependant-pkgs.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 18:07:41 +0000
commit76926159194e180003aa78de97e5f287bf4325a5 (patch)
tree2cea7245cdc3f66355900c820c145eba90598766 /doc/examples/dependant-pkgs.py
parentInitial commit. (diff)
downloadpython-apt-76926159194e180003aa78de97e5f287bf4325a5.tar.xz
python-apt-76926159194e180003aa78de97e5f287bf4325a5.zip
Adding upstream version 2.7.6.upstream/2.7.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'doc/examples/dependant-pkgs.py')
-rwxr-xr-xdoc/examples/dependant-pkgs.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/examples/dependant-pkgs.py b/doc/examples/dependant-pkgs.py
new file mode 100755
index 0000000..e5985b8
--- /dev/null
+++ b/doc/examples/dependant-pkgs.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+
+import sys
+
+import apt
+
+pkgs = set()
+cache = apt.Cache()
+for pkg in cache:
+ candver = cache._depcache.get_candidate_ver(pkg._pkg)
+ if candver is None:
+ continue
+ dependslist = candver.depends_list
+ for dep in list(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.all_targets():
+ if sys.argv[1] == tpkg.parent_pkg.name:
+ pkgs.add(pkg.name)
+
+main = set()
+universe = set()
+for pkg in pkgs:
+ cand = cache[pkg].candidate
+ if "universe" in cand.section:
+ universe.add(cand.source_name)
+ else:
+ main.add(cand.source_name)
+
+print("main:")
+print("\n".join(sorted(main)))
+print()
+
+print("universe:")
+print("\n".join(sorted(universe)))