formatting output in rpm-python?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

<code>
#!/usr/bin/python

import os, sys, rpm

def readRpmHeader(ts, filename):
  fd = os.open(filename, os.O_RDONLY)
    h = ts.hdrFromFdno(fd)
      os.close(fd)
        return h

	rpm.addMacro("_dbpath",
	"/usr/lib/rpmdb/i386-redhat-linux/redhat")
	redhatts = rpm.TransactionSet()
	redhatts.openDB()

	mi = redhatts.dbMatch('name', sys.argv[1])
	for h in mi:
	  print "%s-%s-%s" % (h['name'], h['version'], h['release'])
	    print h.dsFromHeader('requirename')
</code>

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).

Is there a workaround for this, apart from stripping the first two
characters? And where exactly in the source is this stuff prepended (if
that is the case)?

thanks in advance,

armijn

-- 
 ---------------------------------------------------------------------------
  armijn@xxxxxxxx | http://www.uulug.nl/ | UULug: Utrecht Linux Users Group
 ---------------------------------------------------------------------------


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux