Transformation of contrib/check_GNU_style.sh to a python script

Martin Liška mliska@suse.cz
Fri May 19 13:47:00 GMT 2017


On 05/19/2017 12:39 PM, Tom de Vries wrote:
> On 05/19/2017 11:51 AM, Martin Liška wrote:
>> Hello.
>>
>> I'm sending final (slightly updated) version of the script. I'm also adding Jakub,
>> because I remember he's got another regex patterns he's using for review process?
>> Would it be fine to just remove the old *.sh script, or is it preferred to have
>> them both living next to each other for some time?
>>
> 
> I'd like to keep the old script around for a while, to make comparison between the two scripts easier.

Good, thus I'm going to install the script.

> 
>> Thanks,
>> Martin
>>
>>
>> check_GNU_style.py
>>
>>
>> #!/usr/bin/env python3
>> #
>> # Checks some of the GNU style formatting rules in a set of patches.
>> #
>> # This file is part of GCC.
>> #
>> # GCC is free software; you can redistribute it and/or modify it under
>> # the terms of the GNU General Public License as published by the Free
>> # Software Foundation; either version 3, or (at your option) any later
>> # version.
>> #
>> # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
>> # WARRANTY; without even the implied warranty of MERCHANTABILITY or
>> # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
>> # for more details.
>> #
>> # You should have received a copy of the GNU General Public License
>> # along with GCC; see the file COPYING3.  If not see
>> # <http://www.gnu.org/licenses/>.  */
>> #
>> # The script requires following python packages
>> # (can be installed via "pip 3 install"):
> 
> pip3 (there's a space inbetween pip and 3)
> 
>> #   unidiff
>> #   termcolor
>>
> 
> I'd prefer a formulation that can be copy-pasted to the command line, f.i.:
> ...
> # The script requires python packages, which can be installed via pip3
> # like this:
> # $ pip3 install unidiff termcolor
> ...

Thanks, done that.

> 
> I'm not sure if it's possible in python, but it would be even better to detect the missing packages at runtime and print a message explaining how to install the missing packages.

Yep, it's possible to catch ImportError and error message with command invocation is displayed.

> 
> 
> Anyway, using your explanation I now managed to install the dependencies and run the script. [ Earlier I ran into the missing package error, googled the package, found https://pypi.python.org/pypi/unidiff, ran the suggested install line '$ pip install unidiff', and found that the script still was not working. ]

Yep, pip installs Python2 packages.

Martin

> 
> Thanks,
> - Tom

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Introduce-new-check_GNU_style.py-script.patch
Type: text/x-patch
Size: 10322 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20170519/56ef463e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_GNU_style.py
Type: text/x-python
Size: 9383 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20170519/56ef463e/attachment.py>


More information about the Gcc mailing list