~pythoneers/ubuntu/lucid/python-apt/ltsppa

« back to all changes in this revision

Viewing changes to doc/source/apt/cache.rst

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt, Julian Andres Klode, Michael Vogt
  • Date: 2010-03-23 20:01:22 UTC
  • mfrom: (2.3.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100323200122-3t1elea9fbjqn760
Tags: 0.7.94.2ubuntu1
Updated to the 0.7.9x series (FFe LP: #531518), this
brings us python3 support and a more PEP08 conform
API

[ Julian Andres Klode ]
* python/generic.cc:
  - Fix a memory leak when using old attribute names.
* debian/control:
  - Change priority to standard, keep -doc and -dev on optional.

[ Michael Vogt ]
* apt/cache.py:
  - make cache open silent by default (use apt.progress.base.OpProgress)
* tests/data/aptsources_ports/sources.list:
  - fix ports test-data
* debian/control
  - build against XS-Python-Versions: 2.6, 3.1
* tests/test_apt_cache.py:
  - add simple test for basic cache/dependency iteration
* apt/__init__.py:
  - only show deprecation warnings if PYTHON_APT_DEPRECATION_WARNINGS
    is set in the environment. While we do want to have the new API its
    not feasible to port all apps in the lucid timeframe. Once lucid
    is released we turn the warnings on by default again

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
:mod:`apt.cache` --- The Cache class
2
 
=====================================
3
 
.. automodule:: apt.cache
4
 
 
5
 
The Cache class
6
 
---------------
7
 
 
8
 
.. autoclass:: Cache
9
 
    :members:
10
 
    :undoc-members:
11
 
 
12
 
    .. describe:: cache[pkgname]
13
 
 
14
 
        Return a :class:`Package()` for the package with the name *pkgname*.
15
 
 
16
 
Example
17
 
^^^^^^^
18
 
 
19
 
The following example shows how to load the cache, update it, and upgrade
20
 
all the packages on the system::
21
 
 
22
 
    import apt
23
 
    import apt.progress
24
 
 
25
 
    # First of all, open the cache
26
 
    cache = apt.Cache()
27
 
    # Now, lets update the package list
28
 
    cache.update()
29
 
    # We need to re-open the cache because it needs to read the package list
30
 
    cache.open(None)
31
 
    # Now we can do the same as 'apt-get upgrade' does
32
 
    cache.upgrade()
33
 
    # or we can play 'apt-get dist-upgrade'
34
 
    cache.upgrade(True)
35
 
    # Q: Why does nothing happen?
36
 
    # A: You forgot to call commit()!
37
 
    cache.commit(apt.progress.TextFetchProgress(),
38
 
                 apt.progress.InstallProgress())
39
 
 
40
 
 
41
 
 
42
 
Working with Filters
43
 
--------------------
44
 
.. autoclass:: Filter
45
 
    :members:
46
 
    :inherited-members:
47
 
    :undoc-members:
48
 
 
49
 
.. autoclass:: MarkedChangesFilter
50
 
    :members:
51
 
    :inherited-members:
52
 
    :undoc-members:
53
 
 
54
 
.. autoclass:: FilteredCache
55
 
    :members:
56
 
    :inherited-members:
57
 
    :undoc-members:
58
 
 
59
 
 
60
 
Example
61
 
^^^^^^^
62
 
 
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::
65
 
 
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
71
 
    True
72
 
 
73
 
The ProblemResolver class
74
 
--------------------------
75
 
 
76
 
.. autoclass:: ProblemResolver
77
 
    :members:
78
 
 
79
 
Exceptions
80
 
----------
81
 
.. autoexception:: FetchCancelledException
82
 
.. autoexception:: FetchFailedException
83
 
.. autoexception:: LockFailedException