[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: python-apt: how to get ShortDesc and LongDesc

|--==> Igor Stroh writes:

  IS> Free Ekanayaka wrote:

  >>would someone write me  a sample code on how  to get the ShortDesc 
  >>and LongDesc records from the PkgRecords class?
  >>I think it should start with something like:
  >>cache   = apt_pkg.GetCache() records = apt_pkg.GetPkgRecords(cache) 
  >>package = cache['my_pkg']

  IS> Since there are no API-docs for python-apt, there's only one
  IS> option: use the source :)

Thanks! :)

Maybe we could at least include the code below in


beside the other scripts...

Shall I file a wishlist bug for this?



  IS> ============================8<==========================
  IS> import apt_pkg

  IS> PACKAGE_NAME = "my_pkg"

  IS> apt_pkg.init()
  IS> cache   = apt_pkg.GetCache()
  IS> records = apt_pkg.GetPkgRecords(cache)
  IS> package = cache[PACKAGE_NAME]
  IS> for pack_vers in package.VersionList:
  IS>      for pack_file, index in pack_vers.FileList:
  IS>          records.Lookup((pack_file,index))
  IS>          # ignore Debian dpkg status file lookups
  IS>          if pack_file.IndexType != 'Debian Package Index' and \
  IS>                                                IGNORE_DPKG_STATUS == 1:
  IS>              continue
  IS>          print "ORIGIN:", pack_file.Site
  IS>          print "VERSION:", pack_vers.VerStr
  IS>          print "SHORT DESC:", records.ShortDesc
  IS>          print "LONG DESC:", records.LongDesc
  IS>          print
  IS> ============================8<==========================
  IS> HTH,
  IS> Igor

Reply to: