mydep = mydep[:colon]
return mydep
+_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("*"):
pkgcache[mypkg]=None
return None
-_valid_category = re.compile("^\w[\w-]*")
-
catcache={}
def catpkgsplit(mydata,silent=1):
"""
1. If each exists, it returns [cat, pkgname, version, rev]
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)
- an InvalidData Exception will be thrown
"""
-
- # Categories may contain a-zA-z0-9+_- but cannot start with -
- global _valid_category
- import portage_dep
+
try:
if not catcache[mydata]:
return None
retval=["null"]
p_split=pkgsplit(mydata,silent=silent)
elif len(mysplit)==2:
- if portage_dep._dep_check_strict and \
- not _valid_category.match(mysplit[0]):
- raise InvalidData("Invalid category in %s" %mydata )
retval=[mysplit[0]]
p_split=pkgsplit(mysplit[1],silent=silent)
if not p_split:
( ">sys-apps/portage-2.1", 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?]", False ),
( ">~cate-gory/foo-1.0", False ),
( ">~category/foo-1.0", False ),
( "<~category/foo-1.0", False ),