1. yum search all blah -- still does the old thing. 2. yum search yum alias -- just shows name/summary hits for yum+alias.
3. yum search yum smart -- shows name/summary hits for yum, smart and "traditional" search for yum+smart. 4. yum search 'USB 802.11a' -- does the same old thing. ...this drastically reduces the printed results. --- cli.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- docs/yum.8 | 11 ++++++++--- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/cli.py b/cli.py index 9542b7a..3e837ae 100644 --- a/cli.py +++ b/cli.py @@ -931,22 +931,71 @@ class YumBaseCli(yum.YumBase, output.YumOutput): searchlist = ['name', 'summary', 'description', 'url'] dups = self.conf.showdupesfromrepos args = map(to_unicode, args) + + okeys = set() + akeys = set() # All keys, used to see if nothing matched + mkeys = set() # "Main" set of keys for N/S search (biggest term. hit). + pos = set() + + def _print_match_section(text): + # Print them in the order they were passed + used_keys = [arg for arg in args if arg in keys] + print self.fmtSection(text % ", ".join(used_keys)) + + # First try just the name/summary fields, and if we get any hits + # don't do the other stuff. Unless the user overrides via. "all". + if len(args) > 1 and args[0] == 'all': + args.pop(0) + else: + matching = self.searchGenerator(['name', 'summary'], args, + showdups=dups, keys=True) + for (po, keys, matched_value) in matching: + if keys != okeys: + if akeys: + if len(mkeys) == len(args): + break + print "" + else: + mkeys = set(keys) + _print_match_section(_('N/S Matched: %s')) + okeys = keys + pos.add(po) + akeys.update(keys) + self.matchcallback(po, matched_value, args) + matching = self.searchGenerator(searchlist, args, showdups=dups, keys=True) - + okeys = set() - akeys = set() + + # If we got a hit with just name/summary then we only care about hits + # with _more_ search terms. Thus. if we hit all our search terms. do + # nothing. + if len(mkeys) == len(args): + print "" + if len(args) == 1: + msg = _(' Name and summary matches %sonly%s, use "search all" for everything.') + else: + msg = _(' Full name and summary matches %sonly%s, use "search all" for everything.') + print msg % (self.term.MODE['bold'], self.term.MODE['normal']) + matching = [] + for (po, keys, matched_value) in matching: + if len(keys) <= len(mkeys) or po in pos: + continue # Don't print stuff from N/S... + if keys != okeys: if akeys: print "" - # Print them in the order they were passed - used_keys = [arg for arg in args if arg in keys] - print self.fmtSection(_('Matched: %s') % ", ".join(used_keys)) + _print_match_section(_('Matched: %s')) okeys = keys akeys.update(keys) self.matchcallback(po, matched_value, args) + if mkeys and len(mkeys) != len(args): + print "" + print _(' Name and summary matches %smostly%s, use "search all" for everything.') % (self.term.MODE['bold'], self.term.MODE['normal']) + for arg in args: if arg not in akeys: self.logger.warning(_('Warning: No matches found for: %s'), arg) diff --git a/docs/yum.8 b/docs/yum.8 index 281bf17..d21c9fd 100644 --- a/docs/yum.8 +++ b/docs/yum.8 @@ -155,9 +155,14 @@ or file. Just use a specific name or a file-glob-syntax wildcards to list the packages available or installed that provide that feature or file\&. .IP .IP "\fBsearch\fP" -Is used to find any packages matching a string in the description, summary -and package name fields of an rpm. Useful for finding a package -you do not know by name but know by some word related to it. +This is used to find packages when you know something about the package but +aren't sure of it's name. By default search will try searching just package +names and summaries, but if that "fails" it will then try descriptions and url. + +Yum search orders the results so that those packages matching more terms will +appear first. + +You can force searching everything by specifying "all" as the first argument. .IP .IP "\fBinfo\fP" Is used to list a description and summary information about available -- 1.7.2 _______________________________________________ Yum-devel mailing list Yum-devel@lists.baseurl.org http://lists.baseurl.org/mailman/listinfo/yum-devel