summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-02-04 16:16:15 -0800
committerZac Medico <zmedico@gentoo.org>2011-02-04 16:31:08 -0800
commitb88dde55fae635e4d43634acb62711d8435fcd42 (patch)
tree712f86765db7413ffa7a7bca6083e5728939afc0
parentbddc55460cb4da3d8d329c772018119ba6bcfaaa (diff)
downloadportage-b88dde55fae635e4d43634acb62711d8435fcd42.tar.gz
portage-b88dde55fae635e4d43634acb62711d8435fcd42.tar.bz2
portage-b88dde55fae635e4d43634acb62711d8435fcd42.zip
REQUIRED_USE: fix parens display and test more
-rw-r--r--pym/portage/dep/__init__.py21
-rw-r--r--pym/portage/tests/dep/testCheckRequiredUse.py12
2 files changed, 23 insertions, 10 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 6b125f04c..571f6c1c3 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 a0e10b1e7..54791e016 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()