blob: 3f4aa0c4a28237554b16ac3e14d3585e3ef5235f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)
|