[{"id":31083,"web_url":"https://patchwork.libcamera.org/comment/31083/","msgid":"<20240903182456.GA16183@pendragon.ideasonboard.com>","date":"2024-09-03T18:24:56","subject":"Re: [PATCH v2 1/2] utils: checkstyle: Add a python formatter","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Tue, Sep 03, 2024 at 06:10:54PM +0200, Stefan Klug wrote:\n> Reporting style issues on python files is great, automatically fixing them is\n> even better. Add a call to autopep8 for python files. This fixes the same\n> issues as the ones reported by pycodestyle.\n\nPlease reflow the commit message. You could set up your editor to do so\nautomatically.\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  utils/checkstyle.py | 15 +++++++++++++++\n>  1 file changed, 15 insertions(+)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index c9e41d4149f7..1ee211c3bb9b 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -943,6 +943,21 @@ class IncludeOrderFormatter(Formatter):\n>          return '\\n'.join(lines)\n>  \n>  \n> +class Pep8Formatter(Formatter):\n> +    patterns = ('*.py',)\n> +\n> +    @classmethod\n> +    def format(cls, filename, data):\n> +        try:\n> +            ret = subprocess.run(['autopep8', '--ignore=E501', '-'],\n> +                                 input=data.encode('utf-8'), stdout=subprocess.PIPE)\n> +        except FileNotFoundError:\n> +            issues.append(StyleIssue(0, None, None, 'Please install autopep8 to format python additions'))\n> +            return issues\n> +\n> +        return ret.stdout.decode('utf-8')\n> +\n> +\n>  class StripTrailingSpaceFormatter(Formatter):\n>      patterns = ('*.c', '*.cpp', '*.h', '*.py', 'meson.build')\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E46B3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  3 Sep 2024 18:25:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F3661634E5;\n\tTue,  3 Sep 2024 20:25:31 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A6DC0634A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  3 Sep 2024 20:25:30 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B8EB169;\n\tTue,  3 Sep 2024 20:24:18 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"iIn+EHO2\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1725387858;\n\tbh=E1qh1tdga6OvWAeaDlISc/KLOTKkf8lsWwgM8D6rTxk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=iIn+EHO2O/coJ686n5xVllxHQ4dQKIhP2gw3mltDkrLQL3/Z1SiEYbinlbkyaoHVE\n\tQju+4ALM3FRW6/6/UIrvgwwES+FujrpnvchDu21KayC2cqMTuB9ESrTfUx3M4ioGDZ\n\t3t9VisTwebpa74VZaJ000xp10EKYnLlK3rCqTd68=","Date":"Tue, 3 Sep 2024 21:24:56 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 1/2] utils: checkstyle: Add a python formatter","Message-ID":"<20240903182456.GA16183@pendragon.ideasonboard.com>","References":"<20240903161059.246075-1-stefan.klug@ideasonboard.com>\n\t<20240903161059.246075-2-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240903161059.246075-2-stefan.klug@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":31085,"web_url":"https://patchwork.libcamera.org/comment/31085/","msgid":"<172544391112.129190.12754789393934800214@ping.linuxembedded.co.uk>","date":"2024-09-04T09:58:31","subject":"Re: [PATCH v2 1/2] utils: checkstyle: Add a python formatter","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-09-03 17:10:54)\n> Reporting style issues on python files is great, automatically fixing them is\n> even better. Add a call to autopep8 for python files. This fixes the same\n> issues as the ones reported by pycodestyle.\n> \n\nOhhh this seems like a good helper series!\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/checkstyle.py | 15 +++++++++++++++\n>  1 file changed, 15 insertions(+)\n> \n> diff --git a/utils/checkstyle.py b/utils/checkstyle.py\n> index c9e41d4149f7..1ee211c3bb9b 100755\n> --- a/utils/checkstyle.py\n> +++ b/utils/checkstyle.py\n> @@ -943,6 +943,21 @@ class IncludeOrderFormatter(Formatter):\n>          return '\\n'.join(lines)\n>  \n>  \n> +class Pep8Formatter(Formatter):\n> +    patterns = ('*.py',)\n> +\n> +    @classmethod\n> +    def format(cls, filename, data):\n> +        try:\n> +            ret = subprocess.run(['autopep8', '--ignore=E501', '-'],\n> +                                 input=data.encode('utf-8'), stdout=subprocess.PIPE)\n> +        except FileNotFoundError:\n> +            issues.append(StyleIssue(0, None, None, 'Please install autopep8 to format python additions'))\n> +            return issues\n> +\n> +        return ret.stdout.decode('utf-8')\n> +\n> +\n>  class StripTrailingSpaceFormatter(Formatter):\n>      patterns = ('*.c', '*.cpp', '*.h', '*.py', 'meson.build')\n>  \n> -- \n> 2.43.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D5CB3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Sep 2024 09:58:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9227634CB;\n\tWed,  4 Sep 2024 11:58:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 972766341E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Sep 2024 11:58:35 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0BC3F3C7;\n\tWed,  4 Sep 2024 11:57:23 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Zn/NV2dD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1725443843;\n\tbh=xOrNmdUcyeelGu+UNGwu9pxqoMERftLq70i7UTszmI0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Zn/NV2dDVIOfvPISWDUmvCHfFbMLLpILIEEEZbGG5bvvw8a6Mr1nK62N8ynB48v36\n\tlSUB211zSPcmTJvG4Rq65sbd/s7NvfGmq0Z3XSTigk7v/7uyY+TQR6ypSnYO8zf5sZ\n\tUX6QyH8pe8WafbRhiFIxDYjRZVy2DVkBPSlEWwRk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240903161059.246075-2-stefan.klug@ideasonboard.com>","References":"<20240903161059.246075-1-stefan.klug@ideasonboard.com>\n\t<20240903161059.246075-2-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 1/2] utils: checkstyle: Add a python formatter","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 04 Sep 2024 10:58:31 +0100","Message-ID":"<172544391112.129190.12754789393934800214@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]