summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/dep.py12
-rw-r--r--pym/portage/tests/dep/test_isvalidatom.py8
2 files changed, 12 insertions, 8 deletions
diff --git a/pym/portage/dep.py b/pym/portage/dep.py
index 6881b1734..75d4f4c47 100644
--- a/pym/portage/dep.py
+++ b/pym/portage/dep.py
@@ -557,6 +557,7 @@ def dep_getusedeps( depend ):
open_bracket = depend.find( '[', open_bracket+1 )
return tuple(use_list)
+_valid_category = re.compile("^\w[\w-]*")
_invalid_atom_chars_regexp = re.compile("[()|@]")
def isvalidatom(atom, allow_blockers=False):
@@ -585,10 +586,13 @@ def isvalidatom(atom, allow_blockers=False):
return 0
if allow_blockers and atom.startswith("!"):
atom = atom[1:]
- try:
- mycpv_cps = catpkgsplit(dep_getcpv(atom))
- except InvalidData:
- return 0
+ cpv = dep_getcpv(atom)
+ if cpv:
+ if _valid_category.match(catsplit(cpv)[0]) is None:
+ return 0
+ mycpv_cps = catpkgsplit(cpv)
+ else:
+ mycpv_cps = None
operator = get_operator(atom)
if operator:
if operator[0] in "<>" and remove_slot(atom).endswith("*"):
diff --git a/pym/portage/tests/dep/test_isvalidatom.py b/pym/portage/tests/dep/test_isvalidatom.py
index 512d9b465..2b99b3dcb 100644
--- a/pym/portage/tests/dep/test_isvalidatom.py
+++ b/pym/portage/tests/dep/test_isvalidatom.py
@@ -13,8 +13,7 @@ class IsValidAtom(TestCase):
"""
def testIsValidAtom(self):
-
- self.todo = True
+
tests = [ ( "sys-apps/portage", True ),
( "=sys-apps/portage-2.1", True ),
( "=sys-apps/portage-2.1*", True ),
@@ -26,9 +25,10 @@ class IsValidAtom(TestCase):
( "sys-apps/portage:foo", True ),
( "sys-apps/portage-2.1:foo", False ),
( "sys-apps/portage-2.1:", False ),
+ ( "=sys-apps/portage-2.2*:foo[bar][-baz][doc?][-build?]", True ),
( ">~cate-gory/foo-1.0", False ),
- ( ">~category/foo-1.0", True ),
- ( "<~category/foo-1.0", True ),
+ ( ">~category/foo-1.0", False ),
+ ( "<~category/foo-1.0", False ),
( "###cat/foo-1.0", False ),
( "~sys-apps/portage", False ),
( "portage", False ) ]