From patchwork Wed Nov 23 11:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 120116 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4164FA054F; Wed, 23 Nov 2022 12:22:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D362F42D7D; Wed, 23 Nov 2022 12:22:09 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by mails.dpdk.org (Postfix) with ESMTP id F19CB40E5A for ; Wed, 23 Nov 2022 12:22:08 +0100 (CET) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 8E4823200684; Wed, 23 Nov 2022 06:22:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 23 Nov 2022 06:22:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1669202525; x= 1669288925; bh=0N8WuhrjQ6NkHhphxmOxaDBI07gEWdzcU2bc8PIyLkg=; b=P eQRDh33cx4Fa265PZKPh5X/osn//qHO2OniyUqRpN4QDajBcEAZpRkB0QTOtLben 1W6Ma2/85uWqGnL04aqedFR5DZjEQeSrnnX35wv1C8M3/8gZiOum7B43jLHm+h75 0x/EE+rgxrc7i+SU0P7Dxg+gmXAbawzNoFqTtxb/FUC+r5To+1WxRn1Hct5N2ghd 9yIzU2pnxFWEqVRybU7a4yUGemHV/SQMRnuNXAufUfzmOwQf1Eet7o8ODYv6PxW9 mpWll1W4RFFsOfTMmjU95BZFZnBOVy6pEg3hIP/vqTRddAzkvqPM7PKYQNAoM1jt Y5pPnQa94LZJUr0Syp8tw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1669202525; x= 1669288925; bh=0N8WuhrjQ6NkHhphxmOxaDBI07gEWdzcU2bc8PIyLkg=; b=x MOM1ahZ9SW2+i+swq3J4T35fh9oFEMgaks6r27/Rv8DyFB9W7iEtcMoxCNogu6iL O4TbJZdxeMxy3f9aYo18hNH4xKMPRP4NaRjcZOF8uF9prDJq8URy+hy8OXNI6kPB Dby6v6ZVtr1Gbxk2742Y/0vqlq5FK72hUEJSRWjQTl5hWc0DkvqAQC8o8PbISg6l tu9jif+xOotPOVKbJ+pXsA9AIv6C6uQrs+mw6aPMc/pWqQZv9wFxba8Aq9oYvSnf QzhdJeHZrNSBxxIMfAX2gKn6HRivGDGd0ZcelgzH0aPuOci7GqIoeIwayt96Epsu SUP6BwvDN7je5SZt4Y2cQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedriedugddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedtieffffegfeetlefhkeeuteeuudffjefgleevtdeijedukefg veehteehheegjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Nov 2022 06:22:03 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: juraj.linkes@pantheon.tech, Owen Hilyard , Lijuan Tu Subject: [PATCH v2] devtools: set DTS directory to format check Date: Wed, 23 Nov 2022 12:22:00 +0100 Message-Id: <20221123112200.3109840-1-thomas@monjalon.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221109170921.625192-1-thomas@monjalon.net> References: <20221109170921.625192-1-thomas@monjalon.net> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The script was running on the current directory. If not in the DTS directory, it would re-format every Python files. A new positional argument is added to specify the directory to check. In most cases, the (new) default value should be enough. While updating argument handling, the usage is printed in case of wrong argument. The directory is also printed in headings, and a last heading is added for the summary part. Signed-off-by: Thomas Monjalon Reviewed-by: Owen Hilyard Reviewed-by: Juraj Linkeš Signed-off-by: Thomas Monjalon Reviewed-by: Owen Hilyard Reviewed-by: Juraj Linkeš Tested-by: Juraj Linkeš --- v2: add directory in headings and improve headings --- devtools/dts-check-format.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/devtools/dts-check-format.sh b/devtools/dts-check-format.sh index dc07150775..c9b3702642 100755 --- a/devtools/dts-check-format.sh +++ b/devtools/dts-check-format.sh @@ -3,11 +3,10 @@ # Copyright(c) 2022 University of New Hampshire usage() { - echo "Run formatting and linting programs for DTS. Usage:" - + echo "Usage: $(basename $0) [options] [directory]" + echo 'Options:' # Get source code comments after getopts arguments and print them both grep -E '[a-zA-Z]+\) +#' "$0" | tr -d '#' - exit 0 } format=true @@ -17,7 +16,9 @@ lint=true while getopts "hfl" arg; do case $arg in h) # Display this message + echo 'Run formatting and linting programs for DTS.' usage + exit 0 ;; f) # Don't run formatters format=false @@ -25,17 +26,27 @@ while getopts "hfl" arg; do l) # Don't run linter lint=false ;; - *) + ?) + usage + exit 1 esac done +shift $(($OPTIND - 1)) +directory=$(realpath --relative-base=$(pwd) ${1:-$(dirname $0)/../dts}) +cd $directory || exit 1 + +heading() { + echo $* + echo $* | sed 's/./-/g' # underline +} errors=0 if $format; then if command -v git > /dev/null; then if git rev-parse --is-inside-work-tree >&-; then - echo "Formatting:" + heading "Formatting in $directory/" if command -v black > /dev/null; then echo "Formatting code with black:" black . @@ -72,7 +83,7 @@ if $lint; then if $format; then echo fi - echo "Linting:" + heading "Linting in $directory/" if command -v pylama > /dev/null; then pylama . errors=$((errors + $?)) @@ -83,5 +94,6 @@ if $lint; then fi echo +heading "Summary for $directory/" echo "Found $errors errors" exit $errors