Re: formatting output in rpm-python?

Armijn Hemel <[email protected]> Sat, 17 Jan 2004 14:29:27 +0100
Newsgroups gmane.linux.redhat.rpm.python
Message-ID <[email protected]>
On Fri, Jan 16, 2004 at 12:12:14PM +0100, Armijn Hemel wrote:
> hello,
> 
> I'm playing around a bit with the Python bindings for RPM. I made a small
> script which only pulls from the database what a package requires,
> nothing fancy. But, unlike for example 'rpm -qR <package-name>' I get
> some extra output.

[cut]

> If I run this script, called rpmquery.py, for example like this:
> 
> $ ./rpmquery.py rpm
> 
> I get as output lines like this:
> 
>  R textutils
> 
> It prepends this `R ', which `rpm -qR' does not. I've done some digging
> in the RPM source, but I can't find where it gets prepended. To be
> honest, I find it a bit annoying that this kind of formatting is already
> done for me by the software. I don't think this `R ' is actually
> present in the RPM database itself (please correct me if I'm wrong).

Right, I found the solution (and the `problem' more or less):

  tmp = h.dsFromHeader('requirename')
    for i in tmp:
           print i

gives me tuples like

('textutils', '', 64)

which is far more usable for me :)

Still not sure what exactly goes on around where, but probably some
default formatting when I print the result from
h.dsFromHeader(<something>). But, this solves a lot of my problems now.

armijn

-- 
 ---------------------------------------------------------------------------
  [email protected] | http://www.uulug.nl/ | UULug: Utrecht Linux Users Group
 ---------------------------------------------------------------------------