From 2a2b9e6485950757c59a1d5aa026d7f875311def Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 31 Jan 2011 02:01:48 -0800 Subject: [PATCH] Display: Simplify mask code for bug #58416. Hopefully this makes the logic more understandable, though it may support fewer cases. If we want to handle more cases then hopefully we can do it without making the code too complex. --- pym/_emerge/Package.py | 31 ++++++++++--------- pym/_emerge/resolver/output.py | 11 ++++--- .../package/ebuild/_config/KeywordsManager.py | 23 +++----------- pym/portage/package/ebuild/config.py | 10 ++---- 4 files changed, 28 insertions(+), 47 deletions(-) diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 9f210570d..dcc6a0c46 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -237,25 +237,26 @@ class Package(Task): return True - def accepted_keyword(self): - """returns the keyword used from the ebuild's KEYWORDS string""" + def get_keyword_mask(self): + """returns None, 'missing', or 'unstable'.""" - missing, _keywords = \ - self.root_config.settings._getRawMissingKeywords( - self.cpv, self.metadata) - unmasks = self.root_config.settings._getPKeywords( + missing = self.root_config.settings._getRawMissingKeywords( self.cpv, self.metadata) + if not missing: + return None + if '**' in missing: - return '**' - if missing: # keywords to evaluate - for keyword in _keywords + unmasks: - if keyword == '**': - return keyword - used_keyword = '~' + keyword - if used_keyword in missing: - return used_keyword - return '' + return 'missing' + + global_accept_keywords = frozenset( + self.root_config.settings.get("ACCEPT_KEYWORDS", "").split()) + + for keyword in missing: + if keyword.lstrip("~") in global_accept_keywords: + return 'unstable' + + return 'missing' def isHardMasked(self): """returns a bool if the cpv is in the list of diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index be07656a4..46e22808a 100644 --- a/pym/_emerge/resolver/output.py +++ b/pym/_emerge/resolver/output.py @@ -164,16 +164,17 @@ class Display(object): """ @param pkg: _emerge.Package instance """ - used_keyword = pkg.accepted_keyword() hardmasked = pkg.isHardMasked() mask_str = " " if hardmasked: mask_str = colorize("BAD", "#") - elif not used_keyword: - pass - elif used_keyword not in self.pkgsettings['ACCEPT_KEYWORDS'].split(): - if used_keyword == "**": + else: + keyword_mask = pkg.get_keyword_mask() + + if keyword_mask is None: + pass + elif keyword_mask == "missing": mask_str = colorize("BAD", "*") else: mask_str = colorize("WARN", "~") diff --git a/pym/portage/package/ebuild/_config/KeywordsManager.py b/pym/portage/package/ebuild/_config/KeywordsManager.py index 0b593f6e5..51270f2d3 100644 --- a/pym/portage/package/ebuild/_config/KeywordsManager.py +++ b/pym/portage/package/ebuild/_config/KeywordsManager.py @@ -142,14 +142,13 @@ class KeywordsManager(object): slot, keywords, repo, - global_accept_keywords, - backuped_accept_keywords): + global_accept_keywords): """ Take a package and return a list of any KEYWORDS that the user may need to accept for the given package. If the KEYWORDS are empty, the returned list will contain ** alone (in order to distinguish from the case of "none missing"). This DOES NOT apply any user config - keywording acceptance. + package.accept_keywords acceptance. @param cpv: The package name (for package.keywords support) @type cpv: String @@ -159,29 +158,15 @@ class KeywordsManager(object): @type keywords: String @param global_accept_keywords: The current value of ACCEPT_KEYWORDS @type global_accept_keywords: String - @param backuped_accept_keywords: ACCEPT_KEYWORDS from the backup env - @type backuped_accept_keywords: String @rtype: List @return: lists of KEYWORDS that have not been accepted and the keywords it looked for. """ mygroups = self.getKeywords(cpv, slot, keywords, repo) - # Repoman may modify this attribute as necessary. pgroups = global_accept_keywords.split() - - # Hack: Need to check the env directly here as otherwise stacking - # doesn't work properly as negative values are lost in the config - # object (bug #139600) - if backuped_accept_keywords: - pgroups = self._getEgroups(backuped_accept_keywords.split(), - pgroups) - else: - pgroups = set(pgroups) - - missing = self._getMissingKeywords(cpv, pgroups, mygroups) - - return missing, list(pgroups) + pgroups = set(pgroups) + return self._getMissingKeywords(cpv, pgroups, mygroups) @staticmethod diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 81657aa38..1f943e473 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -1456,7 +1456,7 @@ class config(object): need to accept for the given package. If the KEYWORDS are empty, the returned list will contain ** alone (in order to distinguish from the case of "none missing"). This DOES NOT apply any user config - keywording acceptance. + package.accept_keywords acceptance. @param cpv: The package name (for package.keywords support) @type cpv: String @@ -1466,15 +1466,9 @@ class config(object): @return: lists of KEYWORDS that have not been accepted and the keywords it looked for. """ - - # Hack: Need to check the env directly here as otherwise stacking - # doesn't work properly as negative values are lost in the config - # object (bug #139600) - backuped_accept_keywords = self.configdict["backupenv"].get("ACCEPT_KEYWORDS", "") - return self._keywords_manager.getRawMissingKeywords(cpv, metadata["SLOT"], \ metadata.get("KEYWORDS", ""), metadata.get('repository'), \ - self.get("ACCEPT_KEYWORDS", ""), backuped_accept_keywords) + self.get("ACCEPT_KEYWORDS", "")) def _getPKeywords(self, cpv, metadata): global_accept_keywords = self.get("ACCEPT_KEYWORDS", "") -- 2.26.2