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 1QmTO4-0007tK-0b for garchives@archives.gentoo.org; Thu, 28 Jul 2011 16:24:40 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E71A321C2C0; Thu, 28 Jul 2011 16:24:02 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id AA6E921C1A3 for ; Thu, 28 Jul 2011 16:24:02 +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 18D861B4021 for ; Thu, 28 Jul 2011 16:24:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0F59B80051 for ; Thu, 28 Jul 2011 16:24:01 +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: <5d0ad77204be2449586c1829db33203ffab72f0a.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/portagepm/depend.py gentoopm/portagepm/pkg.py X-VCS-Directories: gentoopm/portagepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 5d0ad77204be2449586c1829db33203ffab72f0a Date: Thu, 28 Jul 2011 16:24:01 +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: b2dbdde4060023a7e345e6c59a20ea05 commit: 5d0ad77204be2449586c1829db33203ffab72f0a Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Thu Jul 28 15:06:25 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Thu Jul 28 15:06:25 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D5d0ad772 Portage: support REQUIRED_USE. --- gentoopm/portagepm/depend.py | 47 ++++++++++++++++++++----------------= ----- gentoopm/portagepm/pkg.py | 8 +++--- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py index f33fd5c..232a84b 100644 --- a/gentoopm/portagepm/depend.py +++ b/gentoopm/portagepm/depend.py @@ -3,31 +3,31 @@ # (c) 2011 Micha=C5=82 G=C3=B3rny # Released under the terms of the 2-clause BSD license. =20 +from collections import namedtuple from portage.dep import paren_reduce, use_reduce =20 from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \ PMAnyOfDep, PMAllOfDep, PMExactlyOneOfDep, PMBaseDep -from gentoopm.portagepm.atom import PortageAtom =20 class PortageBaseDep(PMBaseDep): - def __init__(self, deps, puse): + def __init__(self, deps, args): self._deps =3D deps - self._puse =3D puse + self._args =3D args =20 def __iter__(self): it =3D iter(self._deps) for d in it: if d =3D=3D '||': - yield PortageAnyOfDep(next(it), self._puse) + yield PortageAnyOfDep(next(it), self._args) elif d =3D=3D '&&': - yield PortageAllOfDep(next(it), self._puse) + yield PortageAllOfDep(next(it), self._args) elif d =3D=3D '__xor__?': - yield PortageExactlyOneOfDep(next(it), self._puse) + yield PortageExactlyOneOfDep(next(it), self._args) elif d.endswith('?'): yield PortageConditionalUseDep(next(it), - self._puse, d.rstrip('?')) + self._args, d.rstrip('?')) else: - yield PortageAtom(d) + yield self._args.cls(d) =20 class PortageAnyOfDep(PMAnyOfDep, PortageBaseDep): pass @@ -39,22 +39,23 @@ class PortageExactlyOneOfDep(PMExactlyOneOfDep, Porta= geBaseDep): pass =20 class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep): - def __init__(self, deps, puse, flag): - PortageBaseDep.__init__(self, deps, puse) + def __init__(self, deps, args, flag): + PortageBaseDep.__init__(self, deps, args) self._flag =3D flag =20 @property def enabled(self): - return self._flag in self._puse + return self._flag in self._args.puse + +_argtuple =3D namedtuple('PortageDepArgTuple', ('puse', 'cls')) =20 class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep): - def __init__(self, s, puse): + def __init__(self, s, *args): self._use_reducable =3D not '^^' in s - if not self._use_reducable: - # ARGV, paren_reduce() doesn't handle ^^ - # so we hack it to a __xor__?, UGLY! - self._depstr =3D s.replace('^^', '__xor__?') - PortageBaseDep.__init__(self, None, puse) + # ARGV, paren_reduce() doesn't handle ^^ + # so we hack it to a __xor__?, UGLY! + self._depstr =3D s.replace('^^', '__xor__?') + PortageBaseDep.__init__(self, None, _argtuple(*args)) =20 def __iter__(self): if self._deps is None: @@ -65,13 +66,11 @@ class PortagePackageDepSet(PMPackageDepSet, PortageBa= seDep): def without_conditionals(self): if self._use_reducable: return PortageUncondAllOfDep( - use_reduce(self._depstr, self._puse)) + use_reduce(self._depstr, self._args.puse), + self._args) return PMPackageDepSet.without_conditionals.fget(self) =20 class PortageUncondDep(PortageBaseDep): - def __init__(self, deps): - self._deps =3D deps - @property def without_conditionals(self): return self @@ -80,11 +79,11 @@ class PortageUncondDep(PortageBaseDep): it =3D iter(self._deps) for d in it: if d =3D=3D '||': - yield PortageUncondAnyOfDep(next(it)) + yield PortageUncondAnyOfDep(next(it), self._args) elif d =3D=3D '&&': - yield PortageUncondAllOfDep(next(it)) + yield PortageUncondAllOfDep(next(it), self._args) else: - yield PortageAtom(d) + yield self._args.cls(d) =20 class PortageUncondAnyOfDep(PMAnyOfDep, PortageUncondDep): pass diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py index 221e728..5af125a 100644 --- a/gentoopm/portagepm/pkg.py +++ b/gentoopm/portagepm/pkg.py @@ -171,22 +171,22 @@ class PortageDBCPV(PMPackage, CompletePortageAtom): @property def build_dependencies(self): return PortagePackageDepSet(self._aux_get('DEPEND'), - self._applied_use) + self._applied_use, PortageAtom) =20 @property def run_dependencies(self): return PortagePackageDepSet(self._aux_get('RDEPEND'), - self._applied_use) + self._applied_use, PortageAtom) =20 @property def post_dependencies(self): return PortagePackageDepSet(self._aux_get('PDEPEND'), - self._applied_use) + self._applied_use, PortageAtom) =20 @property def required_use(self): return PortagePackageDepSet(self._aux_get('REQUIRED_USE'), - self._applied_use) + self._applied_use, str) # XXX =20 def __str__(self): return '=3D%s' % self._cpv