home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / python-apt / examples / print_uris.py < prev    next >
Encoding:
Python Source  |  2006-07-27  |  501 b   |  23 lines

  1. #!/usr/bin/env python
  2. #
  3. # a example that prints the URIs of all upgradable packages
  4. #
  5.  
  6. import apt
  7. import apt_pkg
  8.  
  9.  
  10. cache = apt.Cache()
  11. upgradable = filter(lambda p: p.isUpgradable, cache)
  12.  
  13.  
  14. for pkg in upgradable:
  15.     pkg._lookupRecord(True)
  16.     path = apt_pkg.ParseSection(pkg._records.Record)["Filename"]
  17.     cand = pkg._depcache.GetCandidateVer(pkg._pkg)
  18.     for (packagefile,i) in cand.FileList:
  19.         indexfile = cache._list.FindIndex(packagefile)
  20.         if indexfile:
  21.             uri = indexfile.ArchiveURI(path)
  22.             print uri
  23.