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']
Since there are no API-docs for python-apt, there's only one
option: use the source :)
============================8<==========================
import apt_pkg
PACKAGE_NAME = "my_pkg"
IGNORE_DPKG_STATUS = 1
apt_pkg.init()
cache = apt_pkg.GetCache()
records = apt_pkg.GetPkgRecords(cache)
package = cache[PACKAGE_NAME]
for pack_vers in package.VersionList:
for pack_file, index in pack_vers.FileList:
records.Lookup((pack_file,index))
# ignore Debian dpkg status file lookups
if pack_file.IndexType != 'Debian Package Index' and \
IGNORE_DPKG_STATUS == 1:
continue
print "ORIGIN:", pack_file.Site
print "VERSION:", pack_vers.VerStr
print "SHORT DESC:", records.ShortDesc
print "LONG DESC:", records.LongDesc
print
============================8<==========================
HTH,
Igor