1 |
commit: 644eb3fe5455c12bd1f831812bb17ae582acb3bc |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Feb 4 01:38:32 2011 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Feb 4 01:38:32 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=644eb3fe |
7 |
|
8 |
REQUIRED_USE: fix parens display and test |
9 |
|
10 |
--- |
11 |
pym/portage/dep/__init__.py | 7 ++++- |
12 |
pym/portage/tests/dep/testCheckRequiredUse.py | 32 ++++++++++++++++++++++++- |
13 |
2 files changed, 36 insertions(+), 3 deletions(-) |
14 |
|
15 |
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py |
16 |
index 7e9a18a..0300b74 100644 |
17 |
--- a/pym/portage/dep/__init__.py |
18 |
+++ b/pym/portage/dep/__init__.py |
19 |
@@ -2088,11 +2088,14 @@ 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 |
tokens = [] |
27 |
if self._operator is not None: |
28 |
tokens.append(self._operator) |
29 |
|
30 |
- if self._parent is not None: |
31 |
+ if include_parens: |
32 |
tokens.append("(") |
33 |
|
34 |
complex_nesting = False |
35 |
@@ -2111,7 +2114,7 @@ class _RequiredUseBranch(object): |
36 |
if not child._satisfied: |
37 |
tokens.append(child.tounicode()) |
38 |
|
39 |
- if self._parent is not None: |
40 |
+ if include_parens: |
41 |
tokens.append(")") |
42 |
|
43 |
return " ".join(tokens) |
44 |
|
45 |
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py |
46 |
index 0f7a299..0fb9702 100644 |
47 |
--- a/pym/portage/tests/dep/testCheckRequiredUse.py |
48 |
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py |
49 |
@@ -134,7 +134,37 @@ class TestCheckRequiredUse(TestCase): |
50 |
( |
51 |
"^^ ( || ( ( a b ) ) ( c ) )", |
52 |
("a", "b", "c"), |
53 |
- "^^ ( || ( ( a b ) ) ( c ) )" |
54 |
+ "^^ ( || ( a b ) c )" |
55 |
+ ), |
56 |
+ ( |
57 |
+ "a? ( ( c e ) ( b d ) )", |
58 |
+ ("a", "c", "e"), |
59 |
+ "a? ( b d )" |
60 |
+ ), |
61 |
+ ( |
62 |
+ "a? ( ( c e ) ( b d ) )", |
63 |
+ ("a", "b", "c", "e"), |
64 |
+ "a? ( d )" |
65 |
+ ), |
66 |
+ ( |
67 |
+ "^^ ( || ( a b ) ^^ ( b c ) )", |
68 |
+ ("a", "b"), |
69 |
+ "^^ ( || ( a b ) ^^ ( b c ) )" |
70 |
+ ), |
71 |
+ ( |
72 |
+ "^^ ( || ( a b ) ^^ ( b c ) )", |
73 |
+ ["a", "c"], |
74 |
+ "^^ ( || ( a b ) ^^ ( b c ) )" |
75 |
+ ), |
76 |
+ ( |
77 |
+ "^^ ( || ( a b ) ^^ ( b c ) )", |
78 |
+ ["b", "c"], |
79 |
+ "" |
80 |
+ ), |
81 |
+ ( |
82 |
+ "^^ ( || ( a b ) ^^ ( b c ) )", |
83 |
+ ["a", "b", "c"], |
84 |
+ "" |
85 |
) |
86 |
) |
87 |
for required_use, use, expected in test_cases: |