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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BE593138330 for ; Thu, 15 Sep 2016 01:30:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5C9ABE0B25; Thu, 15 Sep 2016 01:30:45 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C771E0B10 for ; Thu, 15 Sep 2016 01:30:44 +0000 (UTC) Received: from naomi.gilbertsystems.net (d192-24-229-26.try.wideopenwest.com [24.192.26.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: floppym) by smtp.gentoo.org (Postfix) with ESMTPSA id 38498340A9F for ; Thu, 15 Sep 2016 01:30:43 +0000 (UTC) From: Mike Gilbert To: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-portage-dev] [PATCH 3/3] news: skip parsing if News-Item-Format is unspecified Date: Wed, 14 Sep 2016 21:30:39 -0400 Message-Id: <20160915013039.15646-3-floppym@gentoo.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160915013039.15646-1-floppym@gentoo.org> References: <20160915013039.15646-1-floppym@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: d7d8310d-360d-4277-8483-5663758a43fd X-Archives-Hash: 910db967dc702f133125af6d0ccc4dc6 --- pym/portage/news.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/pym/portage/news.py b/pym/portage/news.py index 28faf83..6020074 100644 --- a/pym/portage/news.py +++ b/pym/portage/news.py @@ -280,26 +280,26 @@ class NewsItem(object): if news_format is None: invalids.append((0, 'News-Item-Format unspecified')) - - # Parse the rest - for i, line in enumerate(lines): - # Optimization to ignore regex matches on lines that - # will never match - if not line.startswith('D'): - continue - restricts = { _installedRE : DisplayInstalledRestriction, - _profileRE : DisplayProfileRestriction, - _keywordRE : DisplayKeywordRestriction } - for regex, restriction in restricts.items(): - match = regex.match(line) - if match: - restrict = restriction(match.groups()[0].strip(), news_format) - if not restrict.isValid(): - invalids.append((i + 1, line.rstrip("\n"))) - else: - self.restrictions.setdefault( - id(restriction), []).append(restrict) + else: + # Parse the rest + for i, line in enumerate(lines): + # Optimization to ignore regex matches on lines that + # will never match + if not line.startswith('D'): continue + restricts = { _installedRE : DisplayInstalledRestriction, + _profileRE : DisplayProfileRestriction, + _keywordRE : DisplayKeywordRestriction } + for regex, restriction in restricts.items(): + match = regex.match(line) + if match: + restrict = restriction(match.groups()[0].strip(), news_format) + if not restrict.isValid(): + invalids.append((i + 1, line.rstrip("\n"))) + else: + self.restrictions.setdefault( + id(restriction), []).append(restrict) + continue if invalids: self._valid = False -- 2.10.0