1
:mod:`apt.cache` --- The Cache class
2
=====================================
3
.. automodule:: apt.cache
12
.. describe:: cache[pkgname]
14
Return a :class:`Package()` for the package with the name *pkgname*.
19
The following example shows how to load the cache, update it, and upgrade
20
all the packages on the system::
25
# First of all, open the cache
27
# Now, lets update the package list
29
# We need to re-open the cache because it needs to read the package list
31
# Now we can do the same as 'apt-get upgrade' does
33
# or we can play 'apt-get dist-upgrade'
35
# Q: Why does nothing happen?
36
# A: You forgot to call commit()!
37
cache.commit(apt.progress.TextFetchProgress(),
38
apt.progress.InstallProgress())
49
.. autoclass:: MarkedChangesFilter
54
.. autoclass:: FilteredCache
63
This is an example for a filtered cache, which only allows access to the
64
packages whose state has been changed, eg. packages marked for installation::
66
>>> from apt.cache import FilteredCache, Cache, MarkedChangesFilter
67
>>> cache = apt.Cache()
68
>>> changed = apt.FilteredCache(cache)
69
>>> changed.setFilter(MarkedChangesFilter())
70
>>> print len(changed) == len(cache.GetChanges()) # Both need to have same length
73
The ProblemResolver class
74
--------------------------
76
.. autoclass:: ProblemResolver
81
.. autoexception:: FetchCancelledException
82
.. autoexception:: FetchFailedException
83
.. autoexception:: LockFailedException