2010-07-22 14 views
3

Le code suivant utilise le module rpm pour interroger la version d'un package installé. Ce que je voudrais faire est d'interroger un ensemble de paquets spécifiés par un glob, par exemple chercher "python*" plutôt que "python". Est-ce possible en utilisant le module rpm?Globbing avec un module python 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'] 

`

Répondre

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

Parfait, merci. – kdt