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 /tests/old/cache.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 '')
-rw-r--r-- | tests/old/cache.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/old/cache.py b/tests/old/cache.py new file mode 100644 index 0000000..3f4aa0c --- /dev/null +++ b/tests/old/cache.py @@ -0,0 +1,51 @@ +#!/usr/bin/python3 +# +# Test for the pkgCache code +# + +import sys + +import apt_pkg + + +def main(): + apt_pkg.init() + cache = apt_pkg.Cache() + depcache = apt_pkg.DepCache(cache) + depcache.init() + i = 0 + all = cache.package_count + print("Running Cache test on all packages:") + # first, get all pkgs + for pkg in cache.packages: + i += 1 + pkg.name + # then get each version + for ver in pkg.version_list: + # get some version information + ver.file_list + ver.ver_str + ver.arch + ver.depends_listStr + dl = ver.depends_list + # get all dependencies (a dict of string->list, + # e.g. "depends:" -> [ver1,ver2,..] + for dep in dl.keys(): + # get the list of each dependency object + for depVerList in dl[dep]: + for z in depVerList: + # get all TargetVersions of + # the dependency object + for j in z.all_targets(): + j.file_list + ver.ver_str + ver.arch + ver.depends_listStr + j = ver.depends_list + + print("\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100))) + + +if __name__ == "__main__": + main() + sys.exit(0) |