/
githubmirror
/
rpm
Обзор
Документация
Войти
/
githubmirror
/
rpm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
python/examples/rpm-q.py
22 строки
506 B
Jakub Kadlcik
Add real-life examples of Python RPM
26 авг 2024, 08:54
26 авг 2024, 08:54
e927be7
Код
Авторство
О чём код?
#!/usr/bin/python # Query one or more installed packages by their names. # A Python equivalent for `rpm -q hello` import sys import rpm if len(sys.argv) == 1: print("rpm: no arguments given for query") sys.exit(1) ts = rpm.TransactionSet() for name in sys.argv[1:]: mi = ts.dbMatch("name", name) if not mi: print("package {0} is not installed".format(name)) continue # Multiple packages can have the same name for hdr in mi: print(hdr[rpm.RPMTAG_NVRA])