Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > 67e32647b06c0323bf90c6b54a6438d1 > files > 35

rpm-apidocs-4.4.2.3-34.el5.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>rpm: Rpmmi Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li id="current"><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li><a href="functions.html"><span>Data&nbsp;Fields</span></a></li>
  </ul></div>
<h1>Rpmmi Class Reference<br>
<small>
[<a class="el" href="group__python.html">PYTHON API.</a>]</small>
</h1><!-- doxytag: class="Rpmmi" -->A python rpm.mi match iterator object represents the result of a database query.  
<a href="#_details">More...</a>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
A python rpm.mi match iterator object represents the result of a database query. 
<p>
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.<p>
The rpm.mi class conains the following methods:<ul>
<li><a class="el" href="llex_8c.html#63a4975e63fa906cd2432d0e7b65d304">next()</a> -&gt; hdr Return the next header that matches.</li></ul>
<p>
<ul>
<li>pattern(tag,mire,pattern) Specify secondary match criteria.</li></ul>
<p>
To obtain a rpm.mi object to query the database used by a transaction, the ts.match(tag,key,len) method is used.<p>
Here's an example that prints the name of all installed packages: <div class="fragment"><pre class="fragment">        <span class="keyword">import</span> rpm
        ts = rpm.TransactionSet()
        <span class="keywordflow">for</span> h in ts.dbMatch():
            print h['<a class="code" href="structname.html">name</a>']
</pre></div><p>
Here's a more typical example that uses the Name index to retrieve all installed kernel(s): <div class="fragment"><pre class="fragment">        <span class="keyword">import</span> rpm
        ts = rpm.TransactionSet()
        mi = ts.dbMatch('<a class="code" href="structname.html">name</a>', <span class="stringliteral">"kernel"</span>)
        <span class="keywordflow">for</span> h in mi:
            print <span class="stringliteral">"%s-%s-%s"</span> % (h['<a class="code" href="structname.html">name</a>'], h['version'], h['release'])
</pre></div><p>
Finally, here's an example that retrieves all packages whose name matches the glob expression "XFree*": <div class="fragment"><pre class="fragment">        <span class="keyword">import</span> rpm
        ts = rpm.TransactionSet()
        mi = ts.dbMatch()
        mi.pattern('<a class="code" href="structname.html">name</a>', rpm.RPMMIRE_GLOB, <span class="stringliteral">"XFree*"</span>)
        <span class="keywordflow">for</span> h in mi:
            print <span class="stringliteral">"%s-%s-%s"</span> % (h['<a class="code" href="structname.html">name</a>'], h['version'], h['release'])
</pre></div> 
<p>
<hr>The documentation for this class was generated from the following file:<ul>
<li>python/<a class="el" href="rpmmi-py_8c-source.html">rpmmi-py.c</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on 1 Oct 2013 for rpm by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>