Create a new AmbiguousPackageName exception to raise from
authorZac Medico <zmedico@gentoo.org>
Fri, 10 Oct 2008 20:15:43 +0000 (20:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Oct 2008 20:15:43 +0000 (20:15 -0000)
portage.cpv_expand(). It inherits from ValueError, for
backward compatibility with calling code that already
handles ValueError.

svn path=/main/trunk/; revision=11670

pym/portage/__init__.py
pym/portage/exception.py

index 38724fc454a7cbf618cf80f2961da291fbc0f34a..dc21b10d56575dbd3dc272d027d9f47d8015bdc5 100644 (file)
@@ -6617,7 +6617,10 @@ def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
                                        else:
                                                virtual_name_collision = True
                        if not virtual_name_collision:
-                               raise ValueError, matches
+                               # AmbiguousPackageName inherits from ValueError,
+                               # for backward compatibility with calling code
+                               # that already handles ValueError.
+                               raise portage.exception.AmbiguousPackageName(matches)
                elif matches:
                        mykey=matches[0]
 
index ff34993a6cef092c1f77e4850229c3ab31531b2c..6626fa3bfa8e303f167b8c6b47e059bfadbfbb0a 100644 (file)
@@ -67,6 +67,13 @@ class ReadOnlyFileSystem(PortageException):
 class CommandNotFound(PortageException):
        """A required binary was not available or executable"""
 
+class AmbiguousPackageName(ValueError, PortageException):
+       """Raised by portage.cpv_expand() when the package name is ambiguous due
+       to the existence of multiple matches in different categories. This inherits
+       from ValueError, for backward compatibility with calling code that already
+       handles ValueError."""
+       def __str__(self):
+               return ValueError.__str__(self)
 
 class PortagePackageException(PortageException):
        """Malformed or missing package data"""