Skip to content

Commit

Permalink
news: simplify isRelevant() check
Browse files Browse the repository at this point in the history
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: 9e24d01
Fixes: 1ffaa70
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam committed Jan 2, 2023
1 parent f1d98b6 commit 0e56f99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -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).

Expand Down
15 changes: 10 additions & 5 deletions lib/portage/news.py
Expand Up @@ -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

Expand Down

0 comments on commit 0e56f99

Please sign in to comment.