diff options
author | 2010-08-06 04:57:05 -0700 | |
---|---|---|
committer | 2010-08-06 04:57:05 -0700 | |
commit | ec1507373773c320a823524292b24c0d90473ec7 (patch) | |
tree | 68c39f3d44fe6dd9ae4d3f5247a9fbb07ad30b6c | |
parent | Use a regular expression to simplify dblink.getcontents(). (diff) | |
download | portage-multirepo-ec1507373773c320a823524292b24c0d90473ec7.tar.gz portage-multirepo-ec1507373773c320a823524292b24c0d90473ec7.tar.bz2 portage-multirepo-ec1507373773c320a823524292b24c0d90473ec7.zip |
Split out a _getmaskingstatus() method that returns categorized
message objects instead of plain strings.
-rw-r--r-- | pym/portage/package/ebuild/getmaskingstatus.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/pym/portage/package/ebuild/getmaskingstatus.py b/pym/portage/package/ebuild/getmaskingstatus.py index 7211a02d..f1ccd6d9 100644 --- a/pym/portage/package/ebuild/getmaskingstatus.py +++ b/pym/portage/package/ebuild/getmaskingstatus.py @@ -15,12 +15,25 @@ from portage.versions import catpkgsplit, cpv_getkey if sys.hexversion >= 0x3000000: basestring = str +class _MaskReason(object): + + __slots__ = ('category', 'message') + + def __init__(self, category, message): + self.category = category + self.message = message + def getmaskingstatus(mycpv, settings=None, portdb=None): if settings is None: settings = config(clone=portage.settings) if portdb is None: portdb = portage.portdb + return [mreason.message for \ + mreason in _getmaskingstatus(mycpv, settings, portdb)] + +def _getmaskingstatus(mycpv, settings, portdb): + metadata = None installed = False if not isinstance(mycpv, basestring): @@ -40,7 +53,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): except KeyError: if not portdb.cpv_exists(mycpv): raise - return ["corruption"] + return [_MaskReason("corruption", "corruption")] if "?" in metadata["LICENSE"]: settings.setcpv(mycpv, mydb=metadata) metadata["USE"] = settings["PORTAGE_USE"] @@ -51,11 +64,11 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): # profile checking if settings._getProfileMaskAtom(mycpv, metadata): - rValue.append("profile") + rValue.append(_MaskReason("profile", "profile")) # package.mask checking if settings._getMaskAtom(mycpv, metadata): - rValue.append("package.mask") + rValue.append(_MaskReason("package.mask", "package.mask")) # keywords checking eapi = metadata["EAPI"] @@ -65,9 +78,9 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if eapi.startswith("-"): eapi = eapi[1:] if not eapi_is_supported(eapi): - return ["EAPI %s" % eapi] + return [_MaskReason("EAPI", "EAPI %s" % eapi)] elif _eapi_is_deprecated(eapi) and not installed: - return ["EAPI %s" % eapi] + return [_MaskReason("EAPI", "EAPI %s" % eapi)] egroups = settings.configdict["backupenv"].get( "ACCEPT_KEYWORDS", "").split() pgroups = settings["ACCEPT_KEYWORDS"].split() @@ -132,9 +145,9 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if x in allowed_tokens] msg = license_split[:] msg.append("license(s)") - rValue.append(" ".join(msg)) + rValue.append(_MaskReason("LICENSE", " ".join(msg))) except portage.exception.InvalidDependString as e: - rValue.append("LICENSE: "+str(e)) + rValue.append(_MaskReason("LICENSE", "LICENSE: "+str(e))) try: missing_properties = settings._getMissingProperties(mycpv, metadata) @@ -146,13 +159,13 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): if x in allowed_tokens] msg = properties_split[:] msg.append("properties") - rValue.append(" ".join(msg)) + rValue.append(_MaskReason("PROPERTIES", " ".join(msg))) except portage.exception.InvalidDependString as e: - rValue.append("PROPERTIES: "+str(e)) + rValue.append(_MaskReason("PROPERTIES", "PROPERTIES: "+str(e))) # Only show KEYWORDS masks for installed packages # if they're not masked for any other reason. if kmask and (not installed or not rValue): - rValue.append(kmask+" keyword") + rValue.append(_MaskReason("KEYWORDS", kmask + " keyword")) return rValue |