header Class Reference
[PYTHON.]
A python header object represents an RPM package header.
More...
Detailed Description
A python header object represents an RPM package header.
All RPM packages have headers that provide metadata for the package. Header objects can be returned by database queries or loaded from a binary package on disk.
The headerFromPackage function loads the package header from a package on disk. It returns a tuple of a "isSource" flag and the header object. The "isSource" flag is set to 1 if the package header was read from a source rpm or to 0 if the package header was read from a binary rpm.
For example:
import os, rpm
fd = os.open("/tmp/foo-1.0-1.i386.rpm", os.O_RDONLY)
(header, isSource) = rpm.headerFromPackage(fd)
fd.close()
The Python interface to the header data is quite elegant. It presents the data in a dictionary form. We'll take the header we just loaded and access the data within it: print header[rpm.RPMTAG_NAME]
print header[rpm.RPMTAG_VERSION]
print header[rpm.RPMTAG_RELEASE]
in the case of our "foor-1.0-1.i386.rpm" package, this code would output: You make also access the header data by string name: This method of access is a bit slower because the name must be translated into the tag number dynamically. You also must make sure the strings in header lookups don't get translated, or the lookups will fail.
The documentation for this class was generated from the following file:
Generated on Sat Mar 18 05:00:55 2006 for rpm by
1.4.6