Gentoo Archives: gentoo-portage-dev

From: Mike Gilbert <floppym@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] news: Support News-Item-Format 2.0
Date: Sat, 03 Sep 2016 22:13:09
Message-Id: CAJ0EP40kBmAVFrPu8jUx5RqtTrErj5_zTbTFEmiyT3BfX7iWaw@mail.gmail.com
In Reply to: Re: [gentoo-portage-dev] [PATCH] news: Support News-Item-Format 2.0 by Zac Medico
1 On Sat, Sep 3, 2016 at 11:50 AM, Zac Medico <zmedico@g.o> wrote:
2 > On 09/02/2016 01:49 PM, Mike Gilbert wrote:
3 >> Display-If-Installed already supported EAPI 5 atoms.
4 >> Use fnmatch for wildcard support on Display-If-Profile.
5 >> ---
6 >> pym/portage/news.py | 4 ++--
7 >> 1 file changed, 2 insertions(+), 2 deletions(-)
8 >>
9 >> diff --git a/pym/portage/news.py b/pym/portage/news.py
10 >> index 177f9db..d6d2f07 100644
11 >> --- a/pym/portage/news.py
12 >> +++ b/pym/portage/news.py
13 >> @@ -271,7 +271,7 @@ class NewsItem(object):
14 >> # will never match
15 >> format_match = _formatRE.match(line)
16 >> if (format_match is not None and
17 >> - not fnmatch.fnmatch(format_match.group(1), '1.*')):
18 >> + not fnmatch.fnmatch(format_match.group(1), '[12].*')):
19 >> invalids.append((i + 1, line.rstrip('\n')))
20 >> break
21 >> if not line.startswith('D'):
22 >> @@ -325,7 +325,7 @@ class DisplayProfileRestriction(DisplayRestriction):
23 >> self.profile = profile
24 >>
25 >> def checkRestriction(self, **kwargs):
26 >> - if self.profile == kwargs['profile']:
27 >> + if fnmatch.fnmatch(kwargs['profile'], self.profile):
28 >> return True
29 >> return False
30 >>
31 >>
32 >
33 > Looks good.
34 >
35 > If we wanted to be more strict about the input that we accept, we could
36 > limit the profile wildcard match to so that it only works if the format
37 > is 2.* and only supports a terminal /* since that's all that the spec
38 > says is supported.
39
40 I don't know how to implement such a thing off the top if my head.
41 Feel free to replace my code with something more strict.