public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/
Date: Sat,  5 Feb 2011 00:59:38 +0000 (UTC)	[thread overview]
Message-ID: <b88dde55fae635e4d43634acb62711d8435fcd42.zmedico@gentoo> (raw)

commit:     b88dde55fae635e4d43634acb62711d8435fcd42
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  5 00:16:15 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb  5 00:31:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b88dde55

REQUIRED_USE: fix parens display and test more

---
 pym/portage/dep/__init__.py                   |   21 ++++++++++++---------
 pym/portage/tests/dep/testCheckRequiredUse.py |   12 +++++++++++-
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 6b125f0..571f6c1 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2217,7 +2217,8 @@ def check_required_use(required_use, use, iuse_match):
 					if l:
 						stack[level].append(satisfied)
 
-					if node._parent._operator not in ("||", "^^"):
+					if len(node._children) <= 1 or \
+						node._parent._operator not in ("||", "^^"):
 						last_node = node._parent._children.pop()
 						if last_node is not node:
 							raise AssertionError(
@@ -2242,7 +2243,16 @@ def check_required_use(required_use, use, iuse_match):
 					if isinstance(node._children[0], _RequiredUseBranch):
 						node._children[0]._parent = node._parent
 						node = node._children[0]
-
+						if node._operator is None and \
+							node._parent._operator not in ("||", "^^"):
+							last_node = node._parent._children.pop()
+							if last_node is not node:
+								raise AssertionError(
+									"node is not last child of parent")
+							for child in node._children:
+								node._parent._children.append(child)
+								if isinstance(child, _RequiredUseBranch):
+									child._parent = node._parent
 				else:
 					for index, child in enumerate(node._children):
 						if isinstance(child, _RequiredUseBranch) and \
@@ -2287,13 +2297,6 @@ def check_required_use(required_use, use, iuse_match):
 		raise InvalidDependString(
 			_("malformed syntax: '%s'") % required_use)
 
-	if len(tree._children) == 1:
-		child = tree._children[0]
-		if isinstance(child, _RequiredUseBranch) and \
-			child._operator is None:
-			tree = child
-			tree._parent = None
-
 	tree._satisfied = False not in stack[0]
 	return tree
 

diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index a0e10b1..54791e0 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -192,6 +192,11 @@ class TestCheckRequiredUse(TestCase):
 				""
 			),
 			(
+				"( ( ( a ) ) ( ( ( b c ) ) ) )",
+				[""],
+				"a b c"
+			),
+			(
 				"|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
 				[""],
 				"a b c"
@@ -200,7 +205,12 @@ class TestCheckRequiredUse(TestCase):
 				"|| ( ( a ( ( ) ( ) ) ( ( ) ) ( b ( ) c ) ) )",
 				[""],
 				"a b c"
-			)
+			),
+			(
+				"|| ( ( a b c ) ) || ( ( d e f ) )",
+				[""],
+				"a b c d e f"
+			),
 		)
 		for required_use, use, expected in test_cases:
 			result = check_required_use(required_use, use, lambda k: True).tounicode()



             reply	other threads:[~2011-02-05  1:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-05  0:59 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-02-08  0:54 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dep/, pym/portage/tests/dep/ Zac Medico
2011-02-05  0:59 Zac Medico
2011-02-04 21:41 Zac Medico
2011-02-04  6:07 zmedico

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=b88dde55fae635e4d43634acb62711d8435fcd42.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@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