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):
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("*"):
"""
def testIsValidAtom(self):
-
- self.todo = True
+
tests = [ ( "sys-apps/portage", True ),
( "=sys-apps/portage-2.1", True ),
( "=sys-apps/portage-2.1*", True ),
( "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 ) ]