packagekit/helpers/yum-search-details.py

50 lines
1.2 KiB
Python
Raw Normal View History

2007-08-03 04:29:18 -07:00
#!/usr/bin/python
2007-08-22 14:09:05 -07:00
#
# Copyright (C) 2007 Richard Hughes <richard@hughsie.com>
# Copyright (C) 2007 Red Hat Inc, Seth Vidal <skvidal@fedoraproject.org>
2007-08-22 14:09:05 -07:00
#
# Licensed under the GNU General Public License Version 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
2007-08-03 04:29:18 -07:00
import yum
import sys
my = yum.YumBase()
#my.doConfigSetup()
my.conf.cache = 1
2007-08-03 04:29:18 -07:00
options = sys.argv[1]
searchterms = sys.argv[2]
2007-08-03 04:29:18 -07:00
searchlist = ['name', 'summary', 'description', 'group']
res = my.searchGenerator(searchlist, [searchterms])
2007-08-03 04:29:18 -07:00
2007-08-19 16:24:49 -07:00
count = 1
2007-08-03 04:29:18 -07:00
for (pkg,values) in res:
2007-08-19 16:24:49 -07:00
if count > 100:
break
count+=1
installed = '0'
# are we installed?
if my.rpmdb.installed(pkg.name):
installed = '1'
# do we print to stdout?
do_print = 0;
if options == 'installed' and installed == '1':
do_print = 1
elif options == 'available' and installed == '0':
do_print = 1
elif options == 'all':
do_print = 1
# print in correct format
if do_print == 1:
print "package\t%s\t%s\t%s" % (installed, pkg.name, pkg.summary)
2007-08-03 04:29:18 -07:00