Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/
Date: Sat, 05 Feb 2011 00:16:38
Message-Id: 6c9cbe5ab35ba4fd666924fbac4ad63d8f820719.zmedico@gentoo
1 commit: 6c9cbe5ab35ba4fd666924fbac4ad63d8f820719
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Sat Feb 5 00:16:15 2011 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sat Feb 5 00:16:15 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c9cbe5a
7
8 REQUIRED_USE: fix parens display and test more
9
10 ---
11 pym/portage/dep/__init__.py | 21 ++++++++++++---------
12 pym/portage/tests/dep/testCheckRequiredUse.py | 12 +++++++++++-
13 2 files changed, 23 insertions(+), 10 deletions(-)
14
15 diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
16 index 6b125f0..571f6c1 100644
17 --- a/pym/portage/dep/__init__.py
18 +++ b/pym/portage/dep/__init__.py
19 @@ -2217,7 +2217,8 @@ def check_required_use(required_use, use, iuse_match):
20 if l:
21 stack[level].append(satisfied)
22
23 - if node._parent._operator not in ("||", "^^"):
24 + if len(node._children) <= 1 or \
25 + node._parent._operator not in ("||", "^^"):
26 last_node = node._parent._children.pop()
27 if last_node is not node:
28 raise AssertionError(
29 @@ -2242,7 +2243,16 @@ def check_required_use(required_use, use, iuse_match):
30 if isinstance(node._children[0], _RequiredUseBranch):
31 node._children[0]._parent = node._parent
32 node = node._children[0]
33 -
34 + if node._operator is None and \
35 + node._parent._operator not in ("||", "^^"):
36 + last_node = node._parent._children.pop()
37 + if last_node is not node:
38 + raise AssertionError(
39 + "node is not last child of parent")
40 + for child in node._children:
41 + node._parent._children.append(child)
42 + if isinstance(child, _RequiredUseBranch):
43 + child._parent = node._parent
44 else:
45 for index, child in enumerate(node._children):
46 if isinstance(child, _RequiredUseBranch) and \
47 @@ -2287,13 +2297,6 @@ def check_required_use(required_use, use, iuse_match):
48 raise InvalidDependString(
49 _("malformed syntax: '%s'") % required_use)
50
51 - if len(tree._children) == 1:
52 - child = tree._children[0]
53 - if isinstance(child, _RequiredUseBranch) and \
54 - child._operator is None:
55 - tree = child
56 - tree._parent = None
57 -
58 tree._satisfied = False not in stack[0]
59 return tree
60
61
62 diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
63 index a0e10b1..54791e0 100644
64 --- a/pym/portage/tests/dep/testCheckRequiredUse.py
65 +++ b/pym/portage/tests/dep/testCheckRequiredUse.py
66 @@ -192,6 +192,11 @@ class TestCheckRequiredUse(TestCase):
67 ""
68 ),
69 (
70 + "( ( ( a ) ) ( ( ( b c ) ) ) )",
71 + [""],
72 + "a b c"
73 + ),
74 + (
75 "|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
76 [""],
77 "a b c"
78 @@ -200,7 +205,12 @@ class TestCheckRequiredUse(TestCase):
79 "|| ( ( a ( ( ) ( ) ) ( ( ) ) ( b ( ) c ) ) )",
80 [""],
81 "a b c"
82 - )
83 + ),
84 + (
85 + "|| ( ( a b c ) ) || ( ( d e f ) )",
86 + [""],
87 + "a b c d e f"
88 + ),
89 )
90 for required_use, use, expected in test_cases:
91 result = check_required_use(required_use, use, lambda k: True).tounicode()