On Sat, Sep 3, 2016 at 11:50 AM, Zac Medico <zmed...@gentoo.org> wrote:
> On 09/02/2016 01:49 PM, Mike Gilbert wrote:
>> Display-If-Installed already supported EAPI 5 atoms.
>> Use fnmatch for wildcard support on Display-If-Profile.
>> ---
>>  pym/portage/news.py | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/pym/portage/news.py b/pym/portage/news.py
>> index 177f9db..d6d2f07 100644
>> --- a/pym/portage/news.py
>> +++ b/pym/portage/news.py
>> @@ -271,7 +271,7 @@ class NewsItem(object):
>>                       # will never match
>>                       format_match = _formatRE.match(line)
>>                       if (format_match is not None and
>> -                                     not 
>> fnmatch.fnmatch(format_match.group(1), '1.*')):
>> +                                     not 
>> fnmatch.fnmatch(format_match.group(1), '[12].*')):
>>                               invalids.append((i + 1, line.rstrip('\n')))
>>                               break
>>                       if not line.startswith('D'):
>> @@ -325,7 +325,7 @@ class DisplayProfileRestriction(DisplayRestriction):
>>               self.profile = profile
>>
>>       def checkRestriction(self, **kwargs):
>> -             if self.profile == kwargs['profile']:
>> +             if fnmatch.fnmatch(kwargs['profile'], self.profile):
>>                       return True
>>               return False
>>
>>
>
> Looks good.
>
> If we wanted to be more strict about the input that we accept, we could
> limit the profile wildcard match to so that it only works if the format
> is 2.* and only supports a terminal /* since that's all that the spec
> says is supported.

I don't know how to implement such a thing off the top if my head.
Feel free to replace my code with something more strict.

Reply via email to