Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Globbing with python rpm module?

The following code uses the rpm module to query the version of an installed package. What I would like to do is to query a set of packages specified by a glob, for example searching for "python*" rather than "python". Is this possible using the rpm module?

  1 #!/usr/bin/python
  2 
  3 import rpm
  4 
  5 ts = rpm.TransactionSet()
  6 mi = ts.dbMatch("name", "python")
  7 for i in mi:
  8     print i['name'], i['version']

`

like image 310
kdt Avatar asked Nov 28 '25 19:11

kdt


1 Answers

import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
mi.pattern('name', rpm.RPMMIRE_GLOB, 'py*' )
for h in mi:
   # Do something with the header... 
like image 56
m1tk4 Avatar answered Nov 30 '25 07:11

m1tk4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!