diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 18:07:41 +0000 |
commit | 76926159194e180003aa78de97e5f287bf4325a5 (patch) | |
tree | 2cea7245cdc3f66355900c820c145eba90598766 /doc/examples/all_deps.py | |
parent | Initial commit. (diff) | |
download | python-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/all_deps.py')
-rw-r--r-- | doc/examples/all_deps.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/examples/all_deps.py b/doc/examples/all_deps.py new file mode 100644 index 0000000..df8610a --- /dev/null +++ b/doc/examples/all_deps.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +import sys + +import apt + + +def dependencies(cache, pkg, deps, key="Depends"): + # print "pkg: %s (%s)" % (pkg.name, deps) + candver = cache._depcache.get_candidate_ver(pkg._pkg) + if candver is None: + return deps + dependslist = candver.depends_list + if key in dependslist: + for depVerList in dependslist[key]: + for dep in depVerList: + if dep.target_pkg.name in cache: + if ( + pkg.name != dep.target_pkg.name + and dep.target_pkg.name not in deps + ): + deps.add(dep.target_pkg.name) + dependencies(cache, cache[dep.target_pkg.name], deps, key) + return deps + + +pkgname = sys.argv[1] +c = apt.Cache() +pkg = c[pkgname] + +deps = set() + +deps = dependencies(c, pkg, deps, "Depends") +print(" ".join(deps)) + +preDeps = set() +preDeps = dependencies(c, pkg, preDeps, "PreDepends") +print(" ".join(preDeps)) |