home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / html / _sources / apt / cache.txt next >
Encoding:
Text File  |  2009-03-30  |  1.9 KB  |  79 lines

  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.  
  74. Exceptions
  75. ----------
  76. .. autoexception:: FetchCancelledException
  77. .. autoexception:: FetchFailedException
  78. .. autoexception:: LockFailedException
  79.