def __init__(self, **kwargs):
Task.__init__(self, **kwargs)
+ # the SlotObject constructor assigns self.root_config from keyword args
+ # and is an instance of a '_emerge.RootConfig.RootConfig class
self.root = self.root_config.root
self._raw_metadata = _PackageMetadataWrapperBase(self.metadata)
self.metadata = _PackageMetadataWrapper(self, self._raw_metadata)
return True
+ def accepted_keyword(self):
+ """returns the keyword used from the ebuild's KEYWORDS string"""
+
+ keywords = set(self.metadata.get('KEYWORDS').split())
+ accept_keywords = set(self.root_config.settings['ACCEPT_KEYWORDS'].split())
+ used_keyword = list(set.intersection(keywords, accept_keywords))
+ if used_keyword and len(used_keyword) == 1:
+ used_keyword = used_keyword[0]
+ elif len(used_keyword) > 1:
+ # you can raise an error here if you prefer, remove it, or set the correct levels
+ writemsg_level( "_emerge.output.resolver.Display(), too many keywords recieved for pkg: %s, %s"
+ % (pkg.cpv, used_keyword))
+ used_keyword = used_keyword[0]
+ #print "pmaskdict", self.root_config.settings.pmaskdict
+ return used_keyword
+
+ def isHardMasked(self):
+ """returns a bool if the cpv is in the list of
+ expanded pmaskdict[cp] availble ebuilds"""
+ try:
+ # returns a list of mask atoms
+ pmask = self.root_config.settings.pmaskdict[self.cp]
+ except KeyError:
+ pmask = []
+ if pmask:
+ # narrow pmask atoms down to the relevant repo
+ n=[x for x in pmask if x.split('::')[-1] in [self.repo]]
+ # hopefully it is down to only 1 mask atom
+ #print "n =", n
+ #count = 0
+ hardmasked = set()
+ for x in n:
+ #expand the atom to matching available ebuilds
+ m = self.root_config.trees['porttree'].dbapi.xmatch("match-all",x)
+ #print "m =", m
+ for n in m:
+ hardmasked.update([n])
+ #count += 1
+ #print "for x in n: loop count =", count, hardmasked
+ return self.cpv in hardmasked
+ return False
+
+
def _metadata_exception(self, k, e):
# For unicode safety with python-2.x we need to avoid
@param pkg: _emerge.Package instance
Modifies self.verboseadd
"""
- accept_keywords = set(self.portdb.settings['ACCEPT_KEYWORDS'].split())
- keywords = set(self.portdb.aux_get(pkg.cpv, ["KEYWORDS"])[0].split())
- used_keyword = list(set.intersection(keywords, accept_keywords))
- if used_keyword and len(used_keyword) == 1:
- used_keyword = used_keyword[0]
- elif len(used_keyword) > 1:
- # you can raise an error here if you prefer, remove it, or set the correct levels
- writemsg_level( "_emerge.output.resolver.Display(), too many keywords recieved for pkg: %s, %s"
- % (pkg.cpv, used_keyword))
- try:
- pmask = self.portdb.settings.pmaskdict[pkg.cp]
- except KeyError:
- pmask = []
- hardmasked = []
- for x in pmask:
- m = self.portdb.xmatch("match-all",x)
- for n in m:
- if n not in hardmasked:
- hardmasked.append(n)
-
+ used_keyword = pkg.accepted_keyword()
+ hardmasked = pkg.isHardMasked()
text = ''
if '~' in used_keyword:
text = used_keyword
elif not used_keyword:
text = '**'
if text:
- if pkg.cpv in hardmasked:
+ if hardmasked:
self.verboseadd += red('%s ' % text)
else:
self.verboseadd += yellow('%s ' % text)
return
-
def map_to_use_expand(self, myvals, forced_flags=False,
remove_hidden=True):
"""Map use expand variables