public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r10401 - in main/branches/2.1.2: pym tests/portage_dep
@ 2008-05-25  3:13 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-05-25  3:13 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-05-25 03:13:06 +0000 (Sun, 25 May 2008)
New Revision: 10401

Modified:
   main/branches/2.1.2/pym/portage_dep.py
   main/branches/2.1.2/pym/portage_versions.py
   main/branches/2.1.2/tests/portage_dep/test_isvalidatom.py
Log:
Fix isvalidatom() so tests pass, and add a USE deps case to the tests.
(trunk r10399)


Modified: main/branches/2.1.2/pym/portage_dep.py
===================================================================
--- main/branches/2.1.2/pym/portage_dep.py	2008-05-25 03:05:30 UTC (rev 10400)
+++ main/branches/2.1.2/pym/portage_dep.py	2008-05-25 03:13:06 UTC (rev 10401)
@@ -369,6 +369,7 @@
 		mydep = mydep[:colon]
 	return mydep
 
+_valid_category = re.compile("^\w[\w-]*")
 _invalid_atom_chars_regexp = re.compile("[()|?@\[\]]")
 
 def isvalidatom(atom, allow_blockers=False):
@@ -393,10 +394,13 @@
 		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("*"):

Modified: main/branches/2.1.2/pym/portage_versions.py
===================================================================
--- main/branches/2.1.2/pym/portage_versions.py	2008-05-25 03:05:30 UTC (rev 10400)
+++ main/branches/2.1.2/pym/portage_versions.py	2008-05-25 03:13:06 UTC (rev 10401)
@@ -255,8 +255,6 @@
 		pkgcache[mypkg]=None
 		return None
 
-_valid_category = re.compile("^\w[\w-]*")
-
 catcache={}
 def catpkgsplit(mydata,silent=1):
 	"""
@@ -271,13 +269,8 @@
 	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
@@ -290,9 +283,6 @@
 		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:

Modified: main/branches/2.1.2/tests/portage_dep/test_isvalidatom.py
===================================================================
--- main/branches/2.1.2/tests/portage_dep/test_isvalidatom.py	2008-05-25 03:05:30 UTC (rev 10400)
+++ main/branches/2.1.2/tests/portage_dep/test_isvalidatom.py	2008-05-25 03:13:06 UTC (rev 10401)
@@ -22,6 +22,10 @@
 			  ( ">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 ),

-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-05-25  3:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-25  3:13 [gentoo-commits] portage r10401 - in main/branches/2.1.2: pym tests/portage_dep Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox