Changes from Version 1 of YumCodeSnippet/YumSearch

Show
Ignore:
Author:
james (IP: 65.172.155.230)
Timestamp:
02/02/09 15:47:59 (9 years ago)
Comment:

create search snippet

Legend:

Unmodified
Added
Removed
Modified
  • YumCodeSnippet/YumSearch

    v0 v1  
     1Search for packages, using just the package names and summaries. 
     2 
     3{{{ 
     4#!python 
     5my = yum.YumBase() 
     6my.conf.cache = 1 
     7 
     8searchterms = sys.argv[1:] 
     9 
     10# Can be any of name/description/url/summary/etc. 
     11searchlist = ['name', 'summary'] 
     12 
     13print '%s Searching %s' % tuple(['-' * 30] * 2) 
     14res = my.searchGenerator(searchlist, searchterms) 
     15 
     16res = sorted(res, key=lambda x: x[0]) 
     17 
     18seen = set() 
     19for (pkg, values) in res: 
     20    if pkg.name not in seen: 
     21        # Print name/summary 
     22        print "%s : %s" % (pkg.name, pkg.summary) 
     23        seen.add(pkg.name) 
     24}}}