aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gentoo.org>2015-02-14 14:42:16 -0500
committerTim Harder <radhermit@gentoo.org>2015-02-14 18:42:08 -0500
commitd3d9e55ae7aeb82681754398050d6049014e4f1f (patch)
tree323c5928e7f42b7aadf76406c413a5a1a8e67865
parentprofiles: provide access to profile-related iuse_effective (diff)
downloadpkgcore-d3d9e55ae7aeb82681754398050d6049014e4f1f.tar.gz
pkgcore-d3d9e55ae7aeb82681754398050d6049014e4f1f.tar.bz2
pkgcore-d3d9e55ae7aeb82681754398050d6049014e4f1f.zip
domain: pull the generate filter function out of the domain
This moves us further towards externalizing all the masking and visibility support.
-rw-r--r--pkgcore/ebuild/domain.py35
1 files changed, 16 insertions, 19 deletions
diff --git a/pkgcore/ebuild/domain.py b/pkgcore/ebuild/domain.py
index 04ba4181a..ab249743a 100644
--- a/pkgcore/ebuild/domain.py
+++ b/pkgcore/ebuild/domain.py
@@ -75,7 +75,7 @@ def apply_mask_filter(globs, atoms, pkg, mode):
return False
-def _mask_filter(masks, negate=False):
+def make_mask_filter(masks, negate=False):
atoms = defaultdict(list)
globs = []
for m in masks:
@@ -85,8 +85,20 @@ def _mask_filter(masks, negate=False):
globs.append(m)
return delegate(partial(apply_mask_filter, globs, atoms), negate=negate)
-make_mask_filter = partial(_mask_filter, negate=True)
-make_unmask_filter = partial(_mask_filter, negate=False)
+
+def generate_filter(masks, unmasks, *extra):
+ # note that we ignore unmasking if masking isn't specified.
+ # no point, mainly
+ masking = make_mask_filter(masks, negate=True)
+ unmasking = make_mask_filter(unmasks, negate=False)
+ r = ()
+ if masking:
+ if unmasking:
+ r = (packages.OrRestriction(masking, unmasking, disable_inst_caching=True),)
+ else:
+ r = (masking,)
+ return packages.AndRestriction(disable_inst_caching=True, finalize=True, *(r + extra))
+
# ow ow ow ow ow ow....
# this manages a *lot* of crap. so... this is fun.
@@ -363,10 +375,7 @@ class domain(pkgcore.config.domain.domain):
masks.update(pos)
masks.update(pkg_maskers)
unmasks = set(chain(pkg_unmaskers, *profile_unmasks))
- filtered = self.generate_filter(
- make_mask_filter(masks),
- make_unmask_filter(unmasks),
- *vfilters)
+ filtered = generate_filter(masks, unmasks, *vfilters)
if filtered:
wrapped_repo = visibility.filterTree(wrapped_repo, filtered, True)
self.repos_configured_filtered[key] = wrapped_repo
@@ -421,18 +430,6 @@ class domain(pkgcore.config.domain.domain):
return True
return False
- def generate_filter(self, masking, unmasking, *extra):
- # note that we ignore unmasking if masking isn't specified.
- # no point, mainly
- r = ()
- if masking:
- if unmasking:
- r = (packages.OrRestriction(masking, unmasking, disable_inst_caching=True),)
- else:
- r = (masking,)
- vfilter = packages.AndRestriction(disable_inst_caching=True, finalize=True, *(r + extra))
- return vfilter
-
def make_keywords_filter(self, arch, default_keys, accept_keywords,
profile_keywords, incremental=False):
"""Generates a restrict that matches iff the keywords are allowed."""