From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/
Date: Wed, 27 Jul 2011 08:26:43 +0000 (UTC) [thread overview]
Message-ID: <e91eb978fa051988af4707ff19b263bd2883f02b.mgorny@gentoo> (raw)
commit: e91eb978fa051988af4707ff19b263bd2883f02b
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 08:27:28 2011 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 27 08:27:28 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=e91eb978
Portage: support simple USE collapsing.
---
gentoopm/portagepm/depend.py | 21 +++++++++++++--------
gentoopm/portagepm/pkg.py | 35 ++++++++++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/gentoopm/portagepm/depend.py b/gentoopm/portagepm/depend.py
index ac289d4..9421099 100644
--- a/gentoopm/portagepm/depend.py
+++ b/gentoopm/portagepm/depend.py
@@ -10,18 +10,20 @@ from gentoopm.basepm.depend import PMPackageDepSet, PMConditionalDep, \
from gentoopm.portagepm.atom import PortageAtom
class PortageBaseDep(PMBaseDep):
- def __init__(self, deps):
+ def __init__(self, deps, puse):
self._deps = deps
+ self._puse = puse
def __iter__(self):
it = iter(self._deps)
for d in it:
if d == '||':
- yield PortageOneOfDep(next(it))
+ yield PortageOneOfDep(next(it), self._puse)
elif d == '&&':
- yield PortageAllOfDep(next(it))
+ yield PortageAllOfDep(next(it), self._puse)
elif d.endswith('?'):
- yield PortageConditionalUseDep(next(it))
+ yield PortageConditionalUseDep(next(it),
+ self._puse, d.rstrip('?'))
else:
yield PortageAtom(d)
@@ -32,11 +34,14 @@ class PortageAllOfDep(PMAllOfDep, PortageBaseDep):
pass
class PortageConditionalUseDep(PMConditionalDep, PortageBaseDep):
+ def __init__(self, deps, puse, flag):
+ PortageBaseDep.__init__(self, deps, puse)
+ self._flag = flag
+
@property
def enabled(self):
- # XXX
- raise NotImplementedError()
+ return self._flag in self._puse
class PortagePackageDepSet(PMPackageDepSet, PortageBaseDep):
- def __init__(self, s):
- self._deps = paren_reduce(s)
+ def __init__(self, s, puse):
+ PortageBaseDep.__init__(self, paren_reduce(s), puse)
diff --git a/gentoopm/portagepm/pkg.py b/gentoopm/portagepm/pkg.py
index 39e4a59..a85f70d 100644
--- a/gentoopm/portagepm/pkg.py
+++ b/gentoopm/portagepm/pkg.py
@@ -128,16 +128,45 @@ class PortageDBCPV(PMPackage, CompletePortageAtom):
return _get_atom(str(self))
@property
+ def _applied_use(self):
+ class LazyUseGetter(object):
+ def __init__(self, dbapi, cpv):
+ self._cpv = cpv
+ self._dbapi = dbapi
+ self._settings = dbapi.settings
+ self._use_cache = None
+
+ @property
+ def _use_set(self):
+ if self._use_cache is None:
+ s = self._settings.__class__(clone = self._settings)
+ # XXX: repos? _emerge.Package or compatible API?
+ s.setcpv(self._cpv, mydb = self._dbapi)
+ self._use_cache = frozenset(s['PORTAGE_USE'].split())
+ return self._use_cache
+
+ def __iter__(self):
+ return iter(self._use_set)
+
+ def __contains__(self, k):
+ return k in self._use_set
+
+ return LazyUseGetter(self._dbapi, self._cpv)
+
+ @property
def build_dependencies(self):
- return PortagePackageDepSet(self._aux_get('DEPEND'))
+ return PortagePackageDepSet(self._aux_get('DEPEND'),
+ self._applied_use)
@property
def run_dependencies(self):
- return PortagePackageDepSet(self._aux_get('RDEPEND'))
+ return PortagePackageDepSet(self._aux_get('RDEPEND'),
+ self._applied_use)
@property
def post_dependencies(self):
- return PortagePackageDepSet(self._aux_get('PDEPEND'))
+ return PortagePackageDepSet(self._aux_get('PDEPEND'),
+ self._applied_use)
def __str__(self):
return '=%s' % self._cpv
next reply other threads:[~2011-07-27 9:02 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-27 8:26 Michał Górny [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-02-16 10:13 [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ Michał Górny
2013-02-03 19:40 Michał Górny
2012-12-10 17:52 Michał Górny
2011-08-15 7:57 Michał Górny
2011-08-14 14:22 Michał Górny
2011-08-12 7:28 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-28 16:24 Michał Górny
2011-07-27 16:04 Michał Górny
2011-07-26 17:30 Michał Górny
2011-07-26 17:18 Michał Górny
2011-07-25 17:06 Michał Górny
2011-07-21 8:47 Michał Górny
2011-07-21 8:47 Michał Górny
2011-07-20 9:41 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-19 20:53 Michał Górny
2011-07-15 13:32 Michał Górny
2011-07-15 12:34 Michał Górny
2011-07-15 8:39 Michał Górny
2011-07-14 14:05 Michał Górny
2011-07-14 13:31 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-10 22:17 Michał Górny
2011-07-08 7:18 Michał Górny
2011-07-07 9:51 Michał Górny
2011-07-06 20:54 Michał Górny
2011-07-06 16:03 Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e91eb978fa051988af4707ff19b263bd2883f02b.mgorny@gentoo \
--to=mgorny@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox