From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AEE9315808B for ; Mon, 4 Apr 2022 19:05:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43D94E07B3; Mon, 4 Apr 2022 19:05:01 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B7907E0882 for ; Mon, 4 Apr 2022 19:05:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BF286341439 for ; Mon, 4 Apr 2022 19:04:59 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 00A03389 for ; Mon, 4 Apr 2022 19:04:58 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1649099076.a387219c4bdc1510e7958193203fcd29acf6c173.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/manifest.py lib/portage/news.py X-VCS-Directories: lib/portage/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: a387219c4bdc1510e7958193203fcd29acf6c173 X-VCS-Branch: master Date: Mon, 4 Apr 2022 19:04:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 71b86b17-9acf-4067-afff-6b8025601138 X-Archives-Hash: 196dffbe235b310cd3e4fba02a2240e5 commit: a387219c4bdc1510e7958193203fcd29acf6c173 Author: Kenneth Raplee kennethraplee com> AuthorDate: Sat Apr 2 01:16:57 2022 +0000 Commit: Sam James gentoo org> CommitDate: Mon Apr 4 19:04:36 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a387219c Return boolean expressions instead of branching Signed-off-by: Kenneth Raplee kennethraplee.com> Signed-off-by: Sam James gentoo.org> lib/portage/manifest.py | 14 ++++++-------- lib/portage/news.py | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/portage/manifest.py b/lib/portage/manifest.py index ff166faa8..4eb6dc18c 100644 --- a/lib/portage/manifest.py +++ b/lib/portage/manifest.py @@ -112,14 +112,12 @@ class Manifest2Entry(ManifestEntry): return f"{myline} {with_hashes}" def __eq__(self, other): - if ( - not isinstance(other, Manifest2Entry) - or self.type != other.type - or self.name != other.name - or self.hashes != other.hashes - ): - return False - return True + return ( + isinstance(other, Manifest2Entry) + and self.type == other.type + and self.name == other.name + and self.hashes == other.hashes + ) def __ne__(self, other): return not self.__eq__(other) diff --git a/lib/portage/news.py b/lib/portage/news.py index 9f373d3d7..801edb68c 100644 --- a/lib/portage/news.py +++ b/lib/portage/news.py @@ -382,13 +382,12 @@ class DisplayProfileRestriction(DisplayRestriction): self.format = news_format def isValid(self): - if fnmatch.fnmatch(self.format, "1.*") and "*" in self.profile: - return False - if fnmatch.fnmatch(self.format, "2.*") and not _valid_profile_RE.match( - self.profile - ): - return False - return True + return ( + not fnmatch.fnmatch(self.format, "1.*") + or "*" not in self.profile + and not fnmatch.fnmatch(self.format, "2.*") + or _valid_profile_RE.match(self.profile) + ) def checkRestriction(self, **kwargs): if fnmatch.fnmatch(self.format, "2.*") and self.profile.endswith("/*"): @@ -407,9 +406,7 @@ class DisplayKeywordRestriction(DisplayRestriction): self.format = news_format def checkRestriction(self, **kwargs): - if kwargs["config"].get("ARCH", "") == self.keyword: - return True - return False + return kwargs["config"].get("ARCH", "") == self.keyword class DisplayInstalledRestriction(DisplayRestriction): @@ -430,10 +427,7 @@ class DisplayInstalledRestriction(DisplayRestriction): return isvalidatom(self.atom) def checkRestriction(self, **kwargs): - vdb = kwargs["vardb"] - if vdb.match(self.atom): - return True - return False + return kwargs["vardb"].match(self.atom) def count_unread_news(portdb, vardb, repos=None, update=True):