Globe with rpm python module?

The following code uses the module rpmto request the version of the installed package. What I would like to do is to request a set of packages specified by glob, like search "python*", not "python". Is this possible with a module rpm?

  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']

`

+3
source share
1 answer
import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
mi.pattern('name', rpm.RPMMIRE_GLOB, 'py*' )
for h in mi:
   # Do something with the header... 
+5
source

Source: https://habr.com/ru/post/1756034/


All Articles