rpm  5.4.14
Rpmmi Class Reference

A python rpm.mi match iterator object represents the result of a database query. More...

Detailed Description

A python rpm.mi match iterator object represents the result of a database query.

Instances of the rpm.mi object provide access to headers that match certain criteria. Typically, a primary index is accessed to find a set of headers that contain a key, and each header is returned serially.

The rpm.mi class conains the following methods:

To obtain a rpm.mi object to query the database used by a transaction, the ts.match(tag,key,len) method is used.

Here's an example that prints the name of all installed packages:

* import rpm
* ts = rpm.TransactionSet()
* for h in ts.dbMatch():
* print h['name']
*

Here's a more typical example that uses the Name index to retrieve all installed kernel(s):

* import rpm
* ts = rpm.TransactionSet()
* mi = ts.dbMatch('name', "kernel")
* for h in mi:
* print "%s-%s-%s" % (h['name'], h['version'], h['release'])
*

Finally, here's an example that retrieves all packages whose name matches the glob expression "XFree*":

* import rpm
* ts = rpm.TransactionSet()
* mi = ts.dbMatch()
* mi.pattern('name', rpm.RPMMIRE_GLOB, "XFree*")
* for h in mi:
* print "%s-%s-%s" % (h['name'], h['version'], h['release'])
*

The documentation for this class was generated from the following file: