epkginfo: Fix epkginfo to handle ambiguous package names.
authoridl0r <idl0r@gentoo.org>
Wed, 31 Mar 2010 12:45:41 +0000 (12:45 -0000)
committeridl0r <idl0r@gentoo.org>
Wed, 31 Mar 2010 12:45:41 +0000 (12:45 -0000)
svn path=/trunk/gentoolkit/; revision=762

ChangeLog
bin/epkginfo

index 63d781c49eb4a9bb0f95fec33cfd33a2b339fe3a..a011ed5925378b30fc765259cc12395325f8e651 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2010-03-31: Christian Ruppert <idl0r@gentoo.org>
+       * epkginfo: Fix epkginfo to handle ambiguous package names.
+
 2010-03-09: Paul Varner <fuzzyray@gentoo.org>
        * gentoolkit: Add inital py3k support.
        * analyse: Add new analyse utility from dol-sen. This will probably
index 30f2ab5af288f9cb748a56c3b65fd792fc439467..953b4a4ebdcddd8b93cf3dd7500cb9cd983829b3 100755 (executable)
@@ -21,6 +21,7 @@ import sys
 from gentoolkit import equery, errors
 from gentoolkit.equery import mod_usage
 from gentoolkit.equery.meta import main, print_help
+from portage.exception import AmbiguousPackageName
 
 def print_epkginfo_help():
        print(mod_usage(mod_name="epkginfo"))
@@ -34,6 +35,18 @@ if not args or set(('-h', '--help')).intersection(args):
 else:
        try:
                main(args)
+       except AmbiguousPackageName as e:
+               pkgs = e.args[0]
+               for candidate in pkgs:
+                       print(candidate)
+
+               from gentoolkit import pprinter as pp
+               from os.path import basename # To get the short name
+
+               print(file=sys.stderr)
+               print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])),
+                               file=sys.stderr, end="")
+               pp.die(1, "one of the above fully-qualified ebuild names instead.")
        except errors.GentoolkitException as err:
                from gentoolkit import pprinter as pp
                pp.die(1, str(err))