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 1Qlc03-0007UM-BM for garchives@archives.gentoo.org; Tue, 26 Jul 2011 07:24:19 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8B96521C095; Tue, 26 Jul 2011 07:24:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 5FAD821C07A for ; Tue, 26 Jul 2011 07:24:11 +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 E06831BC023 for ; Tue, 26 Jul 2011 07:24:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 475168003F for ; Tue, 26 Jul 2011 07:24:10 +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: Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/basepm/depend.py X-VCS-Directories: gentoopm/basepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: e21be5ccba638ae1588d181db23f0e8380a5836d Date: Tue, 26 Jul 2011 07:24:10 +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: ae2f146fe44bb40f27285e691b958a8c commit: e21be5ccba638ae1588d181db23f0e8380a5836d Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Tue Jul 26 07:12:30 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Tue Jul 26 07:12:30 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3De21be5cc Support removing conditionals from depsets. --- gentoopm/basepm/depend.py | 49 +++++++++++++++++++++++++++++++++++++++= +++++- 1 files changed, 48 insertions(+), 1 deletions(-) diff --git a/gentoopm/basepm/depend.py b/gentoopm/basepm/depend.py index 78e5c02..e504594 100644 --- a/gentoopm/basepm/depend.py +++ b/gentoopm/basepm/depend.py @@ -21,11 +21,46 @@ class PMBaseDep(ABCObject): """ pass =20 + @abstractproperty + def without_conditionals(self): + """ + Return the depspec with all conditionals resolved. + + @type: L{PMUncondDep} + """ + pass + +class PMUncondDep(PMBaseDep): + def __init__(self, parent): + self._parent =3D parent + + @property + def without_conditionals(self): + return self + + def _iter_deps(self, deps): + for d in deps: + if isinstance(d, PMConditionalDep): + if d.enabled: + for d in self._iter_deps(d): + yield d + elif isinstance(d, PMOneOfDep): + yield PMUncondOneOfDep(d) + else: + yield d + + def __iter__(self): + return self._iter_deps(self._parent) + class PMConditionalDep(PMBaseDep): """ A conditional dependency set (enabled by a condition of some kind). """ =20 + @property + def without_conditionals(self): + return PMUncondDep((self,)) + @abstractproperty def enabled(self): """ @@ -36,10 +71,22 @@ class PMConditionalDep(PMBaseDep): pass =20 class PMOneOfDep(PMBaseDep): + """ + A one-of dependency set (C{|| ( ... )}). + """ + + @property + def without_conditionals(self): + return PMUncondOneOfDep(self) + +class PMUncondOneOfDep(PMOneOfDep, PMUncondDep): pass =20 class PMPackageDepSet(PMBaseDep): """ A base class representing a depset of a single package. """ - pass + + @property + def without_conditionals(self): + return PMUncondDep(self)