[英]Globbing with python rpm module?
The following code uses the rpm
module to query the version of an installed package. 以下代码使用rpm
模块查询已安装软件包的版本。 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"
. 我想要做的是查询由glob指定的一组包,例如搜索"python*"
而不是"python"
。 Is this possible using the rpm
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']
` `
import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
mi.pattern('name', rpm.RPMMIRE_GLOB, 'py*' )
for h in mi:
# Do something with the header...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.