Main Page Modules Data Structures File List Data Fields Globals Related Pages
header Class Reference
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.
The documentation for this class was generated from the following file:
Generated at Thu Sep 6 11:32:39 2001 for rpm by
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001