From 0e56f99b34939bf38dcfc0f9edf43a51f6ccf3fe Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 2 Jan 2023 04:52:54 +0000 Subject: [PATCH] news: simplify isRelevant() check Hopefully a bit easier to follow now. I'm also not convinced it was right before, as the previous required every restriction.checkRestriction(...) to be true, while the original code only required *one* to be true per restriction. Thanks to kurly for noticing a recent news item wasn't showing up. Fixes: 9e24d0143450628f334cdb62e579efafd1bfd2ba Fixes: 1ffaa70544f34e93df24c0a175105a900bf272bf Signed-off-by: Sam James --- NEWS | 2 ++ lib/portage/news.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 773df02b0b..cabd52035c 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ Features: * TODO Bug fixes: +* news: Fix matching profile paths with Display-If-Profile in some cases. + * checksum: Rewrite Whirlpool implementation as a C extension to substantially improve performance (bug #885909). diff --git a/lib/portage/news.py b/lib/portage/news.py index 14401814de..f81debe977 100644 --- a/lib/portage/news.py +++ b/lib/portage/news.py @@ -279,11 +279,16 @@ def isRelevant(self, vardb, config, profile): kwargs = {"vardb": vardb, "config": config, "profile": profile} - all_match = all( - restriction.checkRestriction(**kwargs) - for values in self.restrictions.values() - for restriction in values - ) + all_match = True + for values in self.restrictions.values(): + matches = [restriction.checkRestriction(**kwargs) for restriction in values] + any_match = any(matches) + + # If, for a single restriction, we didn't match anything, then we obviously + # didn't match everything, so just bail out. + if not any_match: + all_match = False + break return all_match