Gentoo Archives: gentoo-portage-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 3/3] news: skip parsing if News-Item-Format is unspecified
Date: Thu, 15 Sep 2016 01:30:57
Message-Id: 20160915013039.15646-3-floppym@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/3] test_NewsItem: Add News-Item-Format to template by Mike Gilbert
1 ---
2 pym/portage/news.py | 38 +++++++++++++++++++-------------------
3 1 file changed, 19 insertions(+), 19 deletions(-)
4
5 diff --git a/pym/portage/news.py b/pym/portage/news.py
6 index 28faf83..6020074 100644
7 --- a/pym/portage/news.py
8 +++ b/pym/portage/news.py
9 @@ -280,26 +280,26 @@ class NewsItem(object):
10
11 if news_format is None:
12 invalids.append((0, 'News-Item-Format unspecified'))
13 -
14 - # Parse the rest
15 - for i, line in enumerate(lines):
16 - # Optimization to ignore regex matches on lines that
17 - # will never match
18 - if not line.startswith('D'):
19 - continue
20 - restricts = { _installedRE : DisplayInstalledRestriction,
21 - _profileRE : DisplayProfileRestriction,
22 - _keywordRE : DisplayKeywordRestriction }
23 - for regex, restriction in restricts.items():
24 - match = regex.match(line)
25 - if match:
26 - restrict = restriction(match.groups()[0].strip(), news_format)
27 - if not restrict.isValid():
28 - invalids.append((i + 1, line.rstrip("\n")))
29 - else:
30 - self.restrictions.setdefault(
31 - id(restriction), []).append(restrict)
32 + else:
33 + # Parse the rest
34 + for i, line in enumerate(lines):
35 + # Optimization to ignore regex matches on lines that
36 + # will never match
37 + if not line.startswith('D'):
38 continue
39 + restricts = { _installedRE : DisplayInstalledRestriction,
40 + _profileRE : DisplayProfileRestriction,
41 + _keywordRE : DisplayKeywordRestriction }
42 + for regex, restriction in restricts.items():
43 + match = regex.match(line)
44 + if match:
45 + restrict = restriction(match.groups()[0].strip(), news_format)
46 + if not restrict.isValid():
47 + invalids.append((i + 1, line.rstrip("\n")))
48 + else:
49 + self.restrictions.setdefault(
50 + id(restriction), []).append(restrict)
51 + continue
52
53 if invalids:
54 self._valid = False
55 --
56 2.10.0

Replies