Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:prefix commit in: pym/portage/dep/, pym/portage/tests/dep/
Date: Sat, 05 Feb 2011 20:44:11
Message-Id: 39fe4fcfebab8ce9406165bac511302f01a8ca0e.grobian@gentoo
1 commit: 39fe4fcfebab8ce9406165bac511302f01a8ca0e
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Fri Feb 4 05:42:18 2011 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri Feb 4 05:42:18 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=39fe4fcf
7
8 REQUIRED_USE: fix parens display and test more
9
10 ---
11 pym/portage/dep/__init__.py | 35 ++++++++++++++++++++++--
12 pym/portage/tests/dep/testCheckRequiredUse.py | 17 +++++++++++-
13 2 files changed, 48 insertions(+), 4 deletions(-)
14
15 diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
16 index 0300b74..68e628b 100644
17 --- a/pym/portage/dep/__init__.py
18 +++ b/pym/portage/dep/__init__.py
19 @@ -2088,9 +2088,7 @@ class _RequiredUseBranch(object):
20
21 def tounicode(self):
22
23 - include_parens = self._parent is not None and \
24 - (self._operator is not None or \
25 - self._parent._operator is None)
26 + include_parens = self._parent is not None
27 tokens = []
28 if self._operator is not None:
29 tokens.append(self._operator)
30 @@ -2197,6 +2195,7 @@ def check_required_use(required_use, use, iuse_match):
31 satisfied = is_satisfied(op, l)
32 stack[level].append(satisfied)
33 node._satisfied = satisfied
34 +
35 elif not isinstance(stack[level][-1], bool) and \
36 stack[level][-1][-1] == "?":
37 if is_active(stack[level][-1][:-1]):
38 @@ -2207,12 +2206,42 @@ def check_required_use(required_use, use, iuse_match):
39 else:
40 stack[level].pop()
41 node._satisfied = True
42 + node._parent._children.remove(node)
43 + node = node._parent
44 + continue
45 ignore = True
46
47 if l and not ignore:
48 satisfied = False not in l
49 stack[level].append(satisfied)
50 node._satisfied = satisfied
51 + if node._parent._operator not in ("||", "^^"):
52 + offset = node._parent._children.index(node)
53 + node._parent._children.remove(node)
54 + for i, child in enumerate(node._children):
55 + node._parent._children.insert(offset + i, child)
56 + if isinstance(child, _RequiredUseBranch):
57 + child._parent = node._parent
58 + node = node._parent
59 + continue
60 +
61 + if not node._children:
62 + node._parent._children.remove(node)
63 + elif len(node._children) == 1:
64 + index = node._parent._children.index(node)
65 + node._parent._children[index] = node._children[0]
66 + if isinstance(node._children[0], _RequiredUseBranch):
67 + node._children[0]._parent = node._parent
68 + node = node._children[0]
69 + else:
70 + for index, child in enumerate(node._children):
71 + if isinstance(child, _RequiredUseBranch) and \
72 + child._operator is None and \
73 + len(child._children) == 1:
74 + node._children[index] = child._children[0]
75 + if isinstance(node._children[index],
76 + _RequiredUseBranch):
77 + node._children[index]._parent = node
78
79 node = node._parent
80 else:
81
82 diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
83 index 0fb9702..d6a9d0c 100644
84 --- a/pym/portage/tests/dep/testCheckRequiredUse.py
85 +++ b/pym/portage/tests/dep/testCheckRequiredUse.py
86 @@ -134,7 +134,7 @@ class TestCheckRequiredUse(TestCase):
87 (
88 "^^ ( || ( ( a b ) ) ( c ) )",
89 ("a", "b", "c"),
90 - "^^ ( || ( a b ) c )"
91 + "^^ ( ( a b ) c )"
92 ),
93 (
94 "a? ( ( c e ) ( b d ) )",
95 @@ -147,6 +147,11 @@ class TestCheckRequiredUse(TestCase):
96 "a? ( d )"
97 ),
98 (
99 + "a? ( ( c e ) ( c e b c d e c ) )",
100 + ("a", "c", "e"),
101 + "a? ( b d )"
102 + ),
103 + (
104 "^^ ( || ( a b ) ^^ ( b c ) )",
105 ("a", "b"),
106 "^^ ( || ( a b ) ^^ ( b c ) )"
107 @@ -165,6 +170,16 @@ class TestCheckRequiredUse(TestCase):
108 "^^ ( || ( a b ) ^^ ( b c ) )",
109 ["a", "b", "c"],
110 ""
111 + ),
112 + (
113 + "^^ ( ( a b c ) ( b c d ) )",
114 + ["a", "b", "c"],
115 + ""
116 + ),
117 + (
118 + "^^ ( ( a b c ) ( b c d ) )",
119 + ["a", "b", "c", "d"],
120 + "^^ ( ( a b c ) ( b c d ) )"
121 )
122 )
123 for required_use, use, expected in test_cases: