home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / examples / cache-pkgfile.py < prev    next >
Encoding:
Python Source  |  2009-03-30  |  869 b   |  30 lines

  1. #!/usr/bin/python
  2. import apt_pkg
  3.  
  4.  
  5. def main():
  6.     """Example for PackageFile()"""
  7.     apt_pkg.init()
  8.     cache = apt_pkg.GetCache()
  9.     for pkgfile in cache.FileList:
  10.         print 'Package-File:', pkgfile.FileName
  11.         print 'Index-Type:', pkgfile.IndexType # 'Debian Package Index'
  12.         if pkgfile.NotSource:
  13.             print 'Source: None'
  14.         else:
  15.             if pkgfile.Site:
  16.                 # There is a source, and a site, print the site
  17.                 print 'Source:', pkgfile.Site
  18.             else:
  19.                 # It seems to be a local repository
  20.                 print 'Source: Local package file'
  21.         if pkgfile.NotAutomatic:
  22.             # The system won't be updated automatically (eg. experimental)
  23.             print 'Automatic: No'
  24.         else:
  25.             print 'Automatic: Yes'
  26.         print
  27.  
  28. if __name__ == '__main__':
  29.     main()
  30.