summaryrefslogtreecommitdiff
path: root/doc/source/examples/cache-packages.py
blob: 1abe7cf2ee9595367a8e6b8a2eb18b861797614c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
"""Example for packages. Print all essential and important packages"""

import apt_pkg


def main():
    """Main."""
    apt_pkg.InitConfig()
    apt_pkg.InitSystem()
    cache = apt_pkg.GetCache()
    print "Essential packages:"
    for pkg in cache.Packages:
        if pkg.Essential:
            print " ", pkg.Name
    print "Important packages:"
    for pkg in cache.Packages:
        if pkg.Important:
            print " ", pkg.Name

if __name__ == "__main__":
    main()