* [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-06 13:10 Thomas Sachau
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Sachau @ 2011-02-06 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 644eb3fe5455c12bd1f831812bb17ae582acb3bc
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 01:38:32 2011 +0000
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 01:38:32 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=644eb3fe
REQUIRED_USE: fix parens display and test
---
pym/portage/dep/__init__.py | 7 ++++-
pym/portage/tests/dep/testCheckRequiredUse.py | 32 ++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 7e9a18a..0300b74 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2088,11 +2088,14 @@ class _RequiredUseBranch(object):
def tounicode(self):
+ include_parens = self._parent is not None and \
+ (self._operator is not None or \
+ self._parent._operator is None)
tokens = []
if self._operator is not None:
tokens.append(self._operator)
- if self._parent is not None:
+ if include_parens:
tokens.append("(")
complex_nesting = False
@@ -2111,7 +2114,7 @@ class _RequiredUseBranch(object):
if not child._satisfied:
tokens.append(child.tounicode())
- if self._parent is not None:
+ if include_parens:
tokens.append(")")
return " ".join(tokens)
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index 0f7a299..0fb9702 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -134,7 +134,37 @@ class TestCheckRequiredUse(TestCase):
(
"^^ ( || ( ( a b ) ) ( c ) )",
("a", "b", "c"),
- "^^ ( || ( ( a b ) ) ( c ) )"
+ "^^ ( || ( a b ) c )"
+ ),
+ (
+ "a? ( ( c e ) ( b d ) )",
+ ("a", "c", "e"),
+ "a? ( b d )"
+ ),
+ (
+ "a? ( ( c e ) ( b d ) )",
+ ("a", "b", "c", "e"),
+ "a? ( d )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ("a", "b"),
+ "^^ ( || ( a b ) ^^ ( b c ) )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["a", "c"],
+ "^^ ( || ( a b ) ^^ ( b c ) )"
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["b", "c"],
+ ""
+ ),
+ (
+ "^^ ( || ( a b ) ^^ ( b c ) )",
+ ["a", "b", "c"],
+ ""
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-06 13:10 Thomas Sachau
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Sachau @ 2011-02-06 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 39fe4fcfebab8ce9406165bac511302f01a8ca0e
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 05:42:18 2011 +0000
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 05:42:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=39fe4fcf
REQUIRED_USE: fix parens display and test more
---
pym/portage/dep/__init__.py | 35 ++++++++++++++++++++++--
pym/portage/tests/dep/testCheckRequiredUse.py | 17 +++++++++++-
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 0300b74..68e628b 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2088,9 +2088,7 @@ class _RequiredUseBranch(object):
def tounicode(self):
- include_parens = self._parent is not None and \
- (self._operator is not None or \
- self._parent._operator is None)
+ include_parens = self._parent is not None
tokens = []
if self._operator is not None:
tokens.append(self._operator)
@@ -2197,6 +2195,7 @@ def check_required_use(required_use, use, iuse_match):
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
node._satisfied = satisfied
+
elif not isinstance(stack[level][-1], bool) and \
stack[level][-1][-1] == "?":
if is_active(stack[level][-1][:-1]):
@@ -2207,12 +2206,42 @@ def check_required_use(required_use, use, iuse_match):
else:
stack[level].pop()
node._satisfied = True
+ node._parent._children.remove(node)
+ node = node._parent
+ continue
ignore = True
if l and not ignore:
satisfied = False not in l
stack[level].append(satisfied)
node._satisfied = satisfied
+ if node._parent._operator not in ("||", "^^"):
+ offset = node._parent._children.index(node)
+ node._parent._children.remove(node)
+ for i, child in enumerate(node._children):
+ node._parent._children.insert(offset + i, child)
+ if isinstance(child, _RequiredUseBranch):
+ child._parent = node._parent
+ node = node._parent
+ continue
+
+ if not node._children:
+ node._parent._children.remove(node)
+ elif len(node._children) == 1:
+ index = node._parent._children.index(node)
+ node._parent._children[index] = node._children[0]
+ if isinstance(node._children[0], _RequiredUseBranch):
+ node._children[0]._parent = node._parent
+ node = node._children[0]
+ else:
+ for index, child in enumerate(node._children):
+ if isinstance(child, _RequiredUseBranch) and \
+ child._operator is None and \
+ len(child._children) == 1:
+ node._children[index] = child._children[0]
+ if isinstance(node._children[index],
+ _RequiredUseBranch):
+ node._children[index]._parent = node
node = node._parent
else:
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index 0fb9702..d6a9d0c 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -134,7 +134,7 @@ class TestCheckRequiredUse(TestCase):
(
"^^ ( || ( ( a b ) ) ( c ) )",
("a", "b", "c"),
- "^^ ( || ( a b ) c )"
+ "^^ ( ( a b ) c )"
),
(
"a? ( ( c e ) ( b d ) )",
@@ -147,6 +147,11 @@ class TestCheckRequiredUse(TestCase):
"a? ( d )"
),
(
+ "a? ( ( c e ) ( c e b c d e c ) )",
+ ("a", "c", "e"),
+ "a? ( b d )"
+ ),
+ (
"^^ ( || ( a b ) ^^ ( b c ) )",
("a", "b"),
"^^ ( || ( a b ) ^^ ( b c ) )"
@@ -165,6 +170,16 @@ class TestCheckRequiredUse(TestCase):
"^^ ( || ( a b ) ^^ ( b c ) )",
["a", "b", "c"],
""
+ ),
+ (
+ "^^ ( ( a b c ) ( b c d ) )",
+ ["a", "b", "c"],
+ ""
+ ),
+ (
+ "^^ ( ( a b c ) ( b c d ) )",
+ ["a", "b", "c", "d"],
+ "^^ ( ( a b c ) ( b c d ) )"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-06 13:10 Thomas Sachau
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Sachau @ 2011-02-06 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 3791c8aa4cb242aa2b507b6bac368925aad067b1
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 21:07:52 2011 +0000
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 21:07:52 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3791c8aa
REQUIRED_USE: fix parens display and test more
---
pym/portage/dep/__init__.py | 44 +++++++++++++++++-------
pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 62e96d2..b27d589 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -1,5 +1,5 @@
# deps.py -- Portage dependency resolution functions
-# Copyright 2003-2010 Gentoo Foundation
+# Copyright 2003-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
__all__ = [
@@ -2206,7 +2206,10 @@ def check_required_use(required_use, use, iuse_match):
else:
stack[level].pop()
node._satisfied = True
- node._parent._children.remove(node)
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
node = node._parent
continue
ignore = True
@@ -2216,20 +2219,28 @@ def check_required_use(required_use, use, iuse_match):
stack[level].append(satisfied)
node._satisfied = satisfied
if node._parent._operator not in ("||", "^^"):
- offset = node._parent._children.index(node)
- node._parent._children.pop(offset)
- for i, child in enumerate(node._children):
- node._parent._children.insert(offset + i, child)
+ 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
node = node._parent
continue
if not node._children:
- node._parent._children.remove(node)
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
elif len(node._children) == 1:
- index = node._parent._children.index(node)
- node._parent._children[index] = node._children[0]
+ last_node = node._parent._children.pop()
+ if last_node is not node:
+ raise AssertionError(
+ "node is not last child of parent")
+ node._parent._children.append(node._children[0])
if isinstance(node._children[0], _RequiredUseBranch):
node._children[0]._parent = node._parent
node = node._children[0]
@@ -2238,10 +2249,10 @@ def check_required_use(required_use, use, iuse_match):
if isinstance(child, _RequiredUseBranch) and \
child._operator is None and \
len(child._children) == 1:
- node._children[index] = child._children[0]
- if isinstance(node._children[index],
- _RequiredUseBranch):
- node._children[index]._parent = node
+ child = child._children[0]
+ node._children[index] = child
+ if isinstance(child, _RequiredUseBranch):
+ child._parent = node
node = node._parent
else:
@@ -2277,6 +2288,13 @@ 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 332c5a5..c5a8f53 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -190,6 +190,11 @@ class TestCheckRequiredUse(TestCase):
"^^ ( ( a b c ) ( b c !d ) )",
["a", "b", "c", "d"],
""
+ ),
+ (
+ "|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
+ [""],
+ "a b c"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-06 13:10 Thomas Sachau
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Sachau @ 2011-02-06 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 9ba0d885cddeb7de649e09a2c9276f25c4190b5e
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 4 22:31:32 2011 +0000
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Fri Feb 4 22:31:32 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9ba0d885
check_required_use: clarify operator logic
---
pym/portage/dep/__init__.py | 15 +++++++--------
pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++++
2 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index b27d589..b429e56 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -2187,10 +2187,9 @@ def check_required_use(required_use, use, iuse_match):
if level > 0:
level -= 1
l = stack.pop()
- ignore = False
+ op = None
if stack[level]:
if stack[level][-1] in ("||", "^^"):
- ignore = True
op = stack[level].pop()
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
@@ -2198,13 +2197,12 @@ def check_required_use(required_use, use, iuse_match):
elif not isinstance(stack[level][-1], bool) and \
stack[level][-1][-1] == "?":
- if is_active(stack[level][-1][:-1]):
- op = stack[level].pop()
+ op = stack[level].pop()
+ if is_active(op[:-1]):
satisfied = is_satisfied(op, l)
stack[level].append(satisfied)
node._satisfied = satisfied
else:
- stack[level].pop()
node._satisfied = True
last_node = node._parent._children.pop()
if last_node is not node:
@@ -2212,12 +2210,13 @@ def check_required_use(required_use, use, iuse_match):
"node is not last child of parent")
node = node._parent
continue
- ignore = True
- if l and not ignore:
+ if op is None:
satisfied = False not in l
- stack[level].append(satisfied)
node._satisfied = satisfied
+ if l:
+ stack[level].append(satisfied)
+
if node._parent._operator not in ("||", "^^"):
last_node = node._parent._children.pop()
if last_node is not node:
diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
index c5a8f53..a0e10b1 100644
--- a/pym/portage/tests/dep/testCheckRequiredUse.py
+++ b/pym/portage/tests/dep/testCheckRequiredUse.py
@@ -195,6 +195,11 @@ class TestCheckRequiredUse(TestCase):
"|| ( ( ( ( a ) ) ( ( ( b c ) ) ) ) )",
[""],
"a b c"
+ ),
+ (
+ "|| ( ( a ( ( ) ( ) ) ( ( ) ) ( b ( ) c ) ) )",
+ [""],
+ "a b c"
)
)
for required_use, use, expected in test_cases:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/
@ 2011-02-06 13:10 Thomas Sachau
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Sachau @ 2011-02-06 13:10 UTC (permalink / raw
To: gentoo-commits
commit: 6c9cbe5ab35ba4fd666924fbac4ad63d8f820719
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 5 00:16:15 2011 +0000
Commit: Thomas Sachau <tommy <AT> gentoo <DOT> org>
CommitDate: Sat Feb 5 00:16:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c9cbe5a
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()
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-06 13:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-06 13:10 [gentoo-commits] proj/portage:multilib commit in: pym/portage/dep/, pym/portage/tests/dep/ Thomas Sachau
-- strict thread matches above, loose matches on Subject: below --
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
2011-02-06 13:10 Thomas Sachau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox