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

Re: formatting output in rpm-python?



On Thu, 2004-01-15 at 17:38, 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.
> 
> <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
> 

There is an rpm-python mailing list here:
http://lists.dulug.duke.edu/mailman/listinfo/rpm-python-list

perfect for just this type of question.

-sv





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