{"id":1602,"url":"https://patchwork.libcamera.org/api/patches/1602/?format=json","web_url":"https://patchwork.libcamera.org/patch/1602/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190704093502.27448-1-kieran.bingham@ideasonboard.com>","date":"2019-07-04T09:35:02","name":"[libcamera-devel] utils: checkstyle.py: Add pep8 checker","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"17efd6d30ab1968c8046564a76df4d85cec97c7b","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1602/mbox/","series":[{"id":398,"url":"https://patchwork.libcamera.org/api/series/398/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=398","date":"2019-07-04T09:35:02","name":"[libcamera-devel] utils: checkstyle.py: Add pep8 checker","version":1,"mbox":"https://patchwork.libcamera.org/series/398/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1602/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1602/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 01DA560B2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Jul 2019 11:35:05 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 70EA524B;\n\tThu,  4 Jul 2019 11:35:05 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562232905;\n\tbh=IwIwuP7dqWeoVAcx4ggJAjevj4NU+aLBXRKK8aR0n8k=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=rqXYMyAI9zSE63vccx64232D0rzxBLEyaZ7NtPk0to+mK45sM8vxt2vGagonbnx2r\n\tlbuTSF2PqLQnePGCWg0FlDI9bpSGUjg79E6ENe1c0RJGEYW+fbbC4RTtaoffs7V2VS\n\thIJbe7MD6EmOyCcELZ6ApitEkPpFjhRcA+/ot8Gw=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Thu,  4 Jul 2019 10:35:02 +0100","Message-Id":"<20190704093502.27448-1-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] utils: checkstyle.py: Add pep8 checker","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Thu, 04 Jul 2019 09:35:06 -0000"},"content":"Process python additions with pep8 and report any errors that are added.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n utils/checkstyle.py | 29 +++++++++++++++++++++++++++++\n 1 file changed, 29 insertions(+)\n\nThis checker allows the checkstyle script to self-identify any issue.\nIsn't that recursivly fun?\n\n\nTodo:\n  -  This should not fail if pep8 is not present, and should instead report an\n     issue that pep8 is not installed.\n  -  The line_no_regex should ideally be compiled once per class, or globally?\n     But how then do you access a class object from the class instance...\n  -  All of the pep8 failures in checkstyle.py should be fixed up ...","diff":"diff --git a/utils/checkstyle.py b/utils/checkstyle.py\nindex fab4b116d2ff..a960affc71a9 100755\n--- a/utils/checkstyle.py\n+++ b/utils/checkstyle.py\n@@ -276,6 +276,35 @@ class MesonChecker(StyleChecker):\n         return issues\n \n \n+class Pep8Checker(StyleChecker):\n+    patterns = ('*.py',)\n+\n+    def __init__(self, content):\n+        super().__init__()\n+        self.__content = content\n+        self.__data = \"\".join(content).encode('utf-8')\n+\n+    def check(self, line_numbers):\n+        issues = []\n+        line_no_regex = re.compile('stdin:([0-9]+):([0-9]+)(.*)')\n+\n+        ret = subprocess.run(['pep8', '--ignore=E501', '-'],\n+                             input=self.__data, stdout=subprocess.PIPE)\n+\n+        results = ret.stdout.decode('utf-8').splitlines()\n+        for item in results:\n+            search = re.search(line_no_regex, item)\n+            line_number = int(search.group(1))\n+            position = int(search.group(2))\n+            msg = search.group(3)\n+\n+            if line_number in line_numbers:\n+                line = self.__content[line_number - 1]\n+                issues.append(StyleIssue(line_number, line, msg))\n+\n+        return issues\n+\n+\n # ------------------------------------------------------------------------------\n # Formatters\n #\n","prefixes":["libcamera-devel"]}