Handle the exception in isvalidatom, change it to use a portage exceptoin, thanks...
authorAlec Warner <antarus@gentoo.org>
Thu, 11 Jan 2007 21:38:32 +0000 (21:38 -0000)
committerAlec Warner <antarus@gentoo.org>
Thu, 11 Jan 2007 21:38:32 +0000 (21:38 -0000)
svn path=/main/trunk/; revision=5571

pym/portage_dep.py
pym/portage_versions.py
tests/portage_dep/test_isvalidatom.py

index 34eb8f33da92b6ce4a52321070f47a632c28ea11..56c923886aef71e3e7c96b8b90d1b47bdf82f678 100644 (file)
@@ -20,6 +20,7 @@
 
 import re, string, sys, types
 import portage_exception
+from portage_exception import InvalidData
 from portage_versions import catpkgsplit, catsplit, pkgcmp, pkgsplit, ververify
 
 def cpvequal(cpv1, cpv2):
@@ -359,7 +360,10 @@ def isvalidatom(atom, allow_blockers=False):
                return 0
        if allow_blockers and atom.startswith("!"):
                atom = atom[1:]
-       mycpv_cps = catpkgsplit(dep_getcpv(atom))
+       try:
+               mycpv_cps = catpkgsplit(dep_getcpv(atom))
+       except InvalidData:
+               return 0
        operator = get_operator(atom)
        if operator:
                if operator[0] in "<>" and atom[-1] == "*":
index 706c197fd9119d3e33ab43656431b408bc44f668..b4bbb57005847a091b457021e9696289a11ab1ef 100644 (file)
@@ -10,6 +10,7 @@ suffix_regexp = re.compile("^(alpha|beta|rc|pre|p)(\\d*)$")
 suffix_value = {"pre": -2, "p": 0, "alpha": -4, "beta": -3, "rc": -1}
 endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
 
+from portage_exceptions import InvalidData
 
 def ververify(myver, silent=1):
        if ver_regexp.match(myver):
@@ -262,7 +263,7 @@ def catpkgsplit(mydata,silent=1):
        2.  If cat is not specificed in mydata, cat will be "null"
        3.  if rev does not exist it will be '-r0'
        4.  If cat is invalid (specified but has incorrect syntax)
-               a ValueError will be thrown
+               an InvalidData Exception will be thrown
        """
        
        # Categories may contain a-zA-z0-9+_- but cannot start with -
@@ -280,7 +281,7 @@ def catpkgsplit(mydata,silent=1):
                p_split=pkgsplit(mydata,silent=silent)
        elif len(mysplit)==2:
                if not valid_category.match(mysplit[0]):
-                       raise ValueError("Invalid category in %s" %mydata )
+                       raise InvalidData("Invalid category in %s" %mydata )
                retval=[mysplit[0]]
                p_split=pkgsplit(mysplit[1],silent=silent)
        if not p_split:
index 64b029391ac83e2b8eaffe3a27c68185a5786e98..7835fbd0c984a3be8ddd4b32a017827f9e250013 100644 (file)
@@ -32,9 +32,5 @@ class IsValidAtom(TestCase):
                                atom_type = "valid"
                        else:
                                atom_type = "invalid"
-                       try:
-                               self.assertEqual( bool(isvalidatom( test[0] )), test[1],
-                                       msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) )
-                       except ValueError:
-                               if not test[1]:
-                                       pass
+                       self.assertEqual( bool(isvalidatom( test[0] )), test[1],
+                               msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) )