From patchwork Tue Jan 7 15:44:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2520 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9BA7C605EF for ; Tue, 7 Jan 2020 16:44:46 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 371FA9CE; Tue, 7 Jan 2020 16:44:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1578411886; bh=cQwRL5+lfvo+mMG2/AhLwvHaBrt1GDGKHK00vZYPxQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBbjru6MlgHx5eUsOBQ8zE5WgBFYAeVAmbEzGhNRkSbvzYxRBDmJxtzIZsmqALrxp qESqcQ5erqjHRHx1PEArQ/3S6JPjMDnKJ6ZNS/i44VPakx4kP5x5ZJGWaPN/luhYXQ Rh/94tPZS+OB3VHwXnRPl8DEyG5xzdgUt29SeMwU= From: Kieran Bingham To: LibCamera Devel Date: Tue, 7 Jan 2020 15:44:40 +0000 Message-Id: <20200107154442.17372-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200107154442.17372-1-kieran.bingham@ideasonboard.com> References: <20200107154442.17372-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] utils: checkstyle.py: Fix regex string literal X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 15:44:46 -0000 The checkstyle.py patch has a fault which it identified in itself when updating the regex string. --- utils/checkstyle.py +++ utils/checkstyle.py #105: : W605 invalid escape sequence '\+' + diff_header_regex = re.compile('@@ -([0-9]+)(,[0-9]+)? \+([0-9]+)(,?[0-9]+)? @@') --- 1 potential style issue detected, please review This is documented further at: https://www.flake8rules.com/rules/W605.html Update the string literal prefix to declare a raw byte string for the regex parser. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- utils/checkstyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 335e58f5fddf..41cd3371e81e 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -102,7 +102,7 @@ class DiffHunkSide(object): class DiffHunk(object): - diff_header_regex = re.compile('@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@') + diff_header_regex = re.compile(r'@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@') def __init__(self, line): match = DiffHunk.diff_header_regex.match(line) From patchwork Tue Jan 7 15:44:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2521 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E53A7605EF for ; Tue, 7 Jan 2020 16:44:46 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 84DD2A46; Tue, 7 Jan 2020 16:44:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1578411886; bh=C3W2HaY9yKH5eYgqyZZPEtuJGEy6Z8A1jlyaCVjuDS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+slbIHdeEsvB1TuI8t8I7vFJI7AjgNVfLIMFV2SbzrnpS/HqryaeZD30TY4s50P5 9iI6inZmwJsBKNM0gW1Cxg4UEZCDJbfMERpVlzOFPOGhdhDYnbK/Cs7kjeHV5k/886 YW/etmXavFsOUrPGzz0WgnZmwhH09EjhGOdtOk6I= From: Kieran Bingham To: LibCamera Devel Date: Tue, 7 Jan 2020 15:44:41 +0000 Message-Id: <20200107154442.17372-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200107154442.17372-1-kieran.bingham@ideasonboard.com> References: <20200107154442.17372-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] utils: checkstyle.py: Support single line hunks X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jan 2020 15:44:47 -0000 The checkstyle script expects hunks to be declared with a start line and line count, however the unified diff format [0] declares that a single line hunk will only have the start line: > If a hunk contains just one line, only its start line number appears. > Otherwise its line numbers look like ‘start,count’. An empty hunk is > considered to start at the line that follows the hunk. [0] https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html#Detailed-Unified Attempting to parse a single line hunk results in the following error: File "./utils/checkstyle.py", line 110, in __init__ raise RuntimeError("Malformed diff hunk header '%s'" % line) RuntimeError: Malformed diff hunk header '@@ -1 +1,2 @@ The DiffHunk class only makes use of the start line, and does not utilise the line count, thus update the regex to make the unused groups optional, along with its comma separator. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- utils/checkstyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 41cd3371e81e..ab3b977358c7 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -102,7 +102,7 @@ class DiffHunkSide(object): class DiffHunk(object): - diff_header_regex = re.compile(r'@@ -([0-9]+),([0-9]+) \+([0-9]+),([0-9]+) @@') + diff_header_regex = re.compile(r'@@ -([0-9]+)(,[0-9]+)? \+([0-9]+)(,?[0-9]+)? @@') def __init__(self, line): match = DiffHunk.diff_header_regex.match(line)