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 1Qm7Uj-00078w-Eq for garchives@archives.gentoo.org; Wed, 27 Jul 2011 17:02:05 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 16FBA21C0F2 for ; Wed, 27 Jul 2011 17:02:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 2523821C207 for ; Wed, 27 Jul 2011 16:04:49 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A2B531B402F for ; Wed, 27 Jul 2011 16:04:48 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id A5BE78003D for ; Wed, 27 Jul 2011 16:04:47 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <00be1d0f47dbb2ea5e97f753b0356f0755ff2464.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/portagepm/depend.py X-VCS-Directories: gentoopm/portagepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 00be1d0f47dbb2ea5e97f753b0356f0755ff2464 Date: Wed, 27 Jul 2011 16:04:47 +0000 (UTC) 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: 867e6490a30e9f2d70dd30ca5b0b5b19 commit: 00be1d0f47dbb2ea5e97f753b0356f0755ff2464 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Wed Jul 27 16:05:28 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Wed Jul 27 16:05:28 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D00be1d0f Portage: support dropping conditionals using use_reduce(). --- gentoopm/portagepm/depend.py | 42 ++++++++++++++++++++++++++++++++++++= ++++-- 1 files changed, 40 insertions(+), 2 deletions(-) diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py index 9421099..dd96664 100644 --- a/gentoopm/portagepm/depend.py +++ b/gentoopm/portagepm/depend.py @@ -3,7 +3,7 @@ # (c) 2011 Micha=C5=82 G=C3=B3rny # Released under the terms of the 2-clause BSD license. =20 -from portage.dep import paren_reduce +from portage.dep import paren_reduce, use_reduce =20 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \ PMOneOfDep, PMAllOfDep, PMBaseDep @@ -44,4 +44,42 @@ class PortageConditionalUseDep(PMConditionalDep, Porta= geBaseDep): =20 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep): def __init__(self, s, puse): - PortageBaseDep.__init__(self, paren_reduce(s), puse) + self._depstr =3D s + PortageBaseDep.__init__(self, None, puse) + + def __iter__(self): + if self._deps is None: + self._deps =3D paren_reduce(self._depstr) + return PortageBaseDep.__iter__(self) + + @property + def without_conditionals(self): + return PortageUncondPackageDepSet( + use_reduce(self._depstr, self._puse)) + +class PortageUncondDep(PortageBaseDep): + def __init__(self, deps): + self._deps =3D deps + + @property + def without_conditionals(self): + return self + + def __iter__(self): + it =3D iter(self._deps) + for d in it: + if d =3D=3D '||': + yield PortageUncondOneOfDep(next(it)) + elif d =3D=3D '&&': + yield PortageUncondAllOfDep(next(it)) + else: + yield PortageAtom(d) + +class PortageUncondOneOfDep(PMOneOfDep, PortageUncondDep): + pass + +class PortageUncondAllOfDep(PMAllOfDep, PortageUncondDep): + pass + +class PortageUncondPackageDepSet(PortageUncondDep): + pass