public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico (zmedico)" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] portage r10401 - in main/branches/2.1.2: pym tests/portage_dep
Date: Sun, 25 May 2008 03:13:07 +0000	[thread overview]
Message-ID: <E1K06fT-0007Rf-C2@stork.gentoo.org> (raw)

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



                 reply	other threads:[~2008-05-25  3:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1K06fT-0007Rf-C2@stork.gentoo.org \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox