From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1317B1381F3 for ; Sat, 24 Nov 2012 22:08:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 65B5AE0656; Sat, 24 Nov 2012 22:08:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DEDD6E0656 for ; Sat, 24 Nov 2012 22:08:37 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F06A733D961 for ; Sat, 24 Nov 2012 22:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 63810E5436 for ; Sat, 24 Nov 2012 22:08:35 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1353794903.372d0e0dced3f94ba619e722e8a87f0256d52aea.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/actions.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 372d0e0dced3f94ba619e722e8a87f0256d52aea X-VCS-Branch: master Date: Sat, 24 Nov 2012 22:08:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: f11f13cf-d151-4413-b445-f11fccf16c78 X-Archives-Hash: 8a1baaff79db3e5d46f85922a4028af3 commit: 372d0e0dced3f94ba619e722e8a87f0256d52aea Author: Zac Medico gentoo org> AuthorDate: Sat Nov 24 22:08:23 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Nov 24 22:08:23 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=372d0e0d emerge --info: search similar names, bug #444596 --- pym/_emerge/actions.py | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index b1feba6..cd52ddb 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -22,6 +22,7 @@ from itertools import chain import portage portage.proxy.lazyimport.lazyimport(globals(), + 'portage.dbapi._similar_name_search:similar_name_search', 'portage.debug', 'portage.news:count_unread_news,display_news_notifications', '_emerge.chk_updated_cfg_files:chk_updated_cfg_files', @@ -1366,6 +1367,7 @@ def action_info(settings, trees, myopts, myfiles): bindb = trees[eroot]["bintree"].dbapi for x in myfiles: match_found = False + cp_exists = False installed_match = vardb.match(x) for installed in installed_match: mypkgs.append((installed, "installed")) @@ -1378,6 +1380,9 @@ def action_info(settings, trees, myopts, myfiles): if pkg_type == "binary" and "--usepkg" not in myopts: continue + if not cp_exists and db.cp_list(x.cp): + cp_exists = True + matches = db.match(x) matches.reverse() for match in matches: @@ -1400,8 +1405,34 @@ def action_info(settings, trees, myopts, myfiles): xinfo = "%s for %s" % (xinfo, eroot) writemsg("\nemerge: there are no ebuilds to satisfy %s.\n" % colorize("INFORM", xinfo), noiselevel=-1) - # TODO: Split out --misspell-suggestions code from depgraph - # and call it here. + + if not cp_exists and myopts.get( + "--misspell-suggestions", "y") != "n": + + writemsg("\nemerge: searching for similar names..." + , noiselevel=-1) + + dbs = [vardb] + #if "--usepkgonly" not in myopts: + dbs.append(portdb) + if "--usepkg" in myopts: + dbs.append(bindb) + + matches = similar_name_search(dbs, x) + + if len(matches) == 1: + writemsg("\nemerge: Maybe you meant " + matches[0] + "?\n" + , noiselevel=-1) + elif len(matches) > 1: + writemsg( + "\nemerge: Maybe you meant any of these: %s?\n" % \ + (", ".join(matches),), noiselevel=-1) + else: + # Generally, this would only happen if + # all dbapis are empty. + writemsg(" nothing similar found.\n" + , noiselevel=-1) + return 1 output_buffer = []