From patchwork Tue Apr 16 10:20:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19889 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 87969BE08B for ; Tue, 16 Apr 2024 10:20:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FBAC63361; Tue, 16 Apr 2024 12:20:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NIaQXO0V"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC69461B75 for ; Tue, 16 Apr 2024 12:20:16 +0200 (CEST) Received: from pendragon.ideasonboard.com (85-76-7-196-nat.elisa-mobile.fi [85.76.7.196]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BD180480 for ; Tue, 16 Apr 2024 12:19:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1713262770; bh=0ysXeAsYgh/G5pscAxu49YU+UerAjSZTjeMy2os6Ucc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NIaQXO0VgT1E/LJmAVp34Y4JnkXwf+1EsDrd3Z8OIsfevZn6B3vFLYm9GHaGqMK+M T/Oq5LfhoQIRZqw4c1Zig2y1OJcwfv4jj/UDt3XxWeBPQKgfaABm3qC9g6m3yZaqoc HImUot5wbBCuuT5jzhTo9vC2SLjV5yHMQcrP/ruI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 1/2] utils: checkstyle.py: Use r'' strings for regular expressions Date: Tue, 16 Apr 2024 13:20:03 +0300 Message-ID: <20240416102004.10617-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240416102004.10617-1-laurent.pinchart@ideasonboard.com> References: <20240416102004.10617-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" It's a good practice to use r'' strings for regular expressions in Python, to avoid unexpected interaction with string escape sequences. Use them globally. This allows simplifying escaping in one of the regular expression strings. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- utils/checkstyle.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 84f44a422577..2ab7e50fb0b6 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -569,7 +569,7 @@ class IncludeChecker(StyleChecker): 'limits', 'locale', 'setjmp', 'signal', 'stdarg', 'stddef', 'stdint', 'stdio', 'stdlib', 'string', 'time', 'uchar', 'wchar', 'wctype') - include_regex = re.compile('^#include ') + include_regex = re.compile(r'^#include ') def __init__(self, content): super().__init__() @@ -632,7 +632,7 @@ class MesonChecker(StyleChecker): class Pep8Checker(StyleChecker): patterns = ('*.py',) - results_regex = re.compile('stdin:([0-9]+):([0-9]+)(.*)') + results_regex = re.compile(r'stdin:([0-9]+):([0-9]+)(.*)') def __init__(self, content): super().__init__() @@ -665,7 +665,7 @@ class Pep8Checker(StyleChecker): class ShellChecker(StyleChecker): patterns = ('*.sh',) - results_line_regex = re.compile('In - line ([0-9]+):') + results_line_regex = re.compile(r'In - line ([0-9]+):') def __init__(self, content): super().__init__() @@ -753,7 +753,7 @@ class CLangFormatter(Formatter): class DoxygenFormatter(Formatter): patterns = ('*.c', '*.cpp') - return_regex = re.compile(' +\\* +\\\\return +[a-z]') + return_regex = re.compile(r' +\* +\\return +[a-z]') @classmethod def format(cls, filename, data): @@ -813,7 +813,7 @@ class DPointerFormatter(Formatter): class IncludeOrderFormatter(Formatter): patterns = ('*.cpp', '*.h') - include_regex = re.compile('^#include (["<])([^">]*)([">])') + include_regex = re.compile(r'^#include (["<])([^">]*)([">])') @classmethod def format(cls, filename, data): From patchwork Tue Apr 16 10:20:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 19890 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7EF06BE08B for ; Tue, 16 Apr 2024 10:20:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 284FB63352; Tue, 16 Apr 2024 12:20:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="miRhFwnR"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA36C6333E for ; Tue, 16 Apr 2024 12:20:18 +0200 (CEST) Received: from pendragon.ideasonboard.com (85-76-7-196-nat.elisa-mobile.fi [85.76.7.196]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B8AE512 for ; Tue, 16 Apr 2024 12:19:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1713262772; bh=lLZVedF9/SIqTSWmIXEJOPXTcRAyvwiTA8KlSFa+sfs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=miRhFwnRyAeKqKwefhRSm0iHSi01U22B9ALWgQPeBsP/X7rGi+3aexgdfsFEPd2Mj MyxFbmEDIePjmzC5H/0l9RMnhAM0LXy68CiSCy/3NuICw6ZCiBTD8XOPOE7q1ISeVc onNDaOYCUZkqXWbFCYzdaGcX/l5ehQ7LLXuaZvAs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 2/2] utils: checkstyle.py: Drop period at end of Doxygen one liners Date: Tue, 16 Apr 2024 13:20:04 +0300 Message-ID: <20240416102004.10617-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240416102004.10617-1-laurent.pinchart@ideasonboard.com> References: <20240416102004.10617-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The libcamera documentation style calls for no period at the end of the Doxygen one-liner commands (\brief, \param and \return). Extend the DoxygenFormatter class to drop the period. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- utils/checkstyle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/checkstyle.py b/utils/checkstyle.py index 2ab7e50fb0b6..88078a6171b7 100755 --- a/utils/checkstyle.py +++ b/utils/checkstyle.py @@ -753,6 +753,7 @@ class CLangFormatter(Formatter): class DoxygenFormatter(Formatter): patterns = ('*.c', '*.cpp') + oneliner_regex = re.compile(r'^ +\* +\\(brief|param|return)\b.*\.$') return_regex = re.compile(r' +\* +\\return +[a-z]') @classmethod @@ -768,6 +769,7 @@ class DoxygenFormatter(Formatter): lines.append(line) continue + line = cls.oneliner_regex.sub(lambda m: m.group(0)[:-1], line) line = cls.return_regex.sub(lambda m: m.group(0)[:-1] + m.group(0)[-1].upper(), line) if line.find('*/') != -1: