From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PlERX-000659-B8 for garchives@archives.gentoo.org; Fri, 04 Feb 2011 05:42:55 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 01114E085A; Fri, 4 Feb 2011 05:42:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id AF4CBE085A for ; Fri, 4 Feb 2011 05:42:42 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EC5601B4079 for ; Fri, 4 Feb 2011 05:42:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5B8A98006D for ; Fri, 4 Feb 2011 05:42:41 +0000 (UTC) To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Content-type: text/plain; charset=UTF-8 Message-ID: <39fe4fcfebab8ce9406165bac511302f01a8ca0e.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dep/, pym/portage/tests/dep/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dep/__init__.py pym/portage/tests/dep/testCheckRequiredUse.py X-VCS-Directories: pym/portage/dep/ pym/portage/tests/dep/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 39fe4fcfebab8ce9406165bac511302f01a8ca0e Date: Fri, 4 Feb 2011 05:42:41 +0000 (UTC) From: zmedico@gentoo.org Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: b742455610b29414924c1d568543d192 commit: 39fe4fcfebab8ce9406165bac511302f01a8ca0e Author: Zac Medico gentoo org> AuthorDate: Fri Feb 4 05:42:18 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Feb 4 05:42:18 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D39fe4fcfebab8ce9406165bac511302f01a8ca0e 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): =20 def tounicode(self): =20 - include_parens =3D self._parent is not None and \ - (self._operator is not None or \ - self._parent._operator is None) + include_parens =3D self._parent is not None tokens =3D [] if self._operator is not None: tokens.append(self._operator) @@ -2197,6 +2195,7 @@ def check_required_use(required_use, use, iuse_matc= h): satisfied =3D is_satisfied(op, l) stack[level].append(satisfied) node._satisfied =3D satisfied + elif not isinstance(stack[level][-1], bool) and \ stack[level][-1][-1] =3D=3D "?": if is_active(stack[level][-1][:-1]): @@ -2207,12 +2206,42 @@ def check_required_use(required_use, use, iuse_ma= tch): else: stack[level].pop() node._satisfied =3D True + node._parent._children.remove(node) + node =3D node._parent + continue ignore =3D True =20 if l and not ignore: satisfied =3D False not in l stack[level].append(satisfied) node._satisfied =3D satisfied + if node._parent._operator not in ("||", "^^"): + offset =3D 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 =3D node._parent + node =3D node._parent + continue + + if not node._children: + node._parent._children.remove(node) + elif len(node._children) =3D=3D 1: + index =3D node._parent._children.index(node) + node._parent._children[index] =3D node._children[0] + if isinstance(node._children[0], _RequiredUseBranch): + node._children[0]._parent =3D node._parent + node =3D node._children[0] + else: + for index, child in enumerate(node._children): + if isinstance(child, _RequiredUseBranch) and \ + child._operator is None and \ + len(child._children) =3D=3D 1: + node._children[index] =3D child._children[0] + if isinstance(node._children[index], + _RequiredUseBranch): + node._children[index]._parent =3D node =20 node =3D 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: