From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26642A04A9; Wed, 2 Mar 2022 19:43:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E55CE4068B; Wed, 2 Mar 2022 19:43:04 +0100 (CET) Received: from mail-pl1-f227.google.com (mail-pl1-f227.google.com [209.85.214.227]) by mails.dpdk.org (Postfix) with ESMTP id E3BC140141 for ; Wed, 2 Mar 2022 19:43:03 +0100 (CET) Received: by mail-pl1-f227.google.com with SMTP id s1so2317125plg.12 for ; Wed, 02 Mar 2022 10:43:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZiE9GbXe2k4eeMqpnIqs9iA/BJdhkfQsqFxUgpkSYMY=; b=J3yt3dVqoNmb326fGnA61li45Ma8r5APXzxT0ECZvdzj2lUEwZrLAsK6Lxelr48gux H1eJ9mVDbKFkUVOxigSAYoRO5kZXs/4TuGGUVTxRTPusbxroQBQ62tIML6RrzMguoAAv LXokLi8cg2zRkpAXW211Y8ZT+84mEogIrmeVA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZiE9GbXe2k4eeMqpnIqs9iA/BJdhkfQsqFxUgpkSYMY=; b=Klu/6eK2IJabSGDF6MnObLC+fThGOxkPHLIpJ3TbP6HjIV5/gpwvJsTprsVQaIm9Ne riioNjhIy2oDJm62BtJmHy9tANGj47qrEgrnQj+6yZr5TantRCskMCQLVoxKceP2Qqno PoSMICmI6cAPTdyM7HR5O7wJ5uh2xbDBkW25F6LZ0weq0Cu2BlCPkcSrl5T+hEkLW0OX 6ikkm2mALlyz3kvos18doQbmAdTdLzdabnrKgV9Lm7c1XO/jdosC/S6I6U5mvCHGS/r5 tqsBb62g6j59ejuVFSmnYt6DYN0mwLynZ2xF4Da1kYRQe3u7kZlk8ytRebXov0fDFpJM RBUQ== X-Gm-Message-State: AOAM533WB+2fpyUOzqikEa5ZN3HrdzeoXHnZsuSdYU6rLOlmlRAACUoD YJjxVgukUzIaS5jje/HAVquIVX26UyVMG8UPSiHCC8ly4/17TFHqZiCvZ8KCo+MRMP33Y29CvI/ 3rX3NHpRmiAlWili+YH1rx7oYf7OmdJZxECJTH4MxToYpWssOo/ECZ3xOB2RxOwHwQqlRFMYOMg == X-Google-Smtp-Source: ABdhPJwK6EHhS0ZvlgAs9EGWVKZ/elaSNtaSdwS9lD4FbgBGMwanTS/RG039YaM8i4hb2/giPFMaAsQIv9bw X-Received: by 2002:a17:902:b490:b0:14c:da4a:deca with SMTP id y16-20020a170902b49000b0014cda4adecamr32142444plr.134.1646246582924; Wed, 02 Mar 2022 10:43:02 -0800 (PST) Received: from postal.iol.unh.edu (postal.iol.unh.edu. [132.177.123.84]) by smtp-relay.gmail.com with ESMTPS id x21-20020a17090a8a9500b001bee86e2cdesm210702pjn.0.2022.03.02.10.43.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2022 10:43:02 -0800 (PST) X-Relaying-Domain: iol.unh.edu Received: from iol.unh.edu (unknown [IPv6:2606:4100:3880:1257::105d]) by postal.iol.unh.edu (Postfix) with ESMTP id E4711605246B; Wed, 2 Mar 2022 13:43:01 -0500 (EST) From: ohilyard@iol.unh.edu To: dts@dpdk.org Cc: lijuan.tu@intel.com, Owen Hilyard Subject: [PATCH] formatting_script: Add formatting script Date: Wed, 2 Mar 2022 13:42:56 -0500 Message-Id: <20220302184255.35984-1-ohilyard@iol.unh.edu> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org From: Owen Hilyard Added a formatting script to run black an isort with. By default, it will run in the current working directory. If $1 is specified and not either "-h" or "--help", it will run in that directory instead. This does not allow checking for a git diff after formatting (for rejecting patches in CI), but that should be fairly easy to implement in a wrapper script. Signed-off-by: Owen Hilyard --- format.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 format.sh diff --git a/format.sh b/format.sh new file mode 100755 index 00000000..d35c0bf1 --- /dev/null +++ b/format.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +function main() { + # The directory to work on is either passed in as argument 1, + # or is the current working directory + DIRECTORY=${1:-`pwd`} + LINE_LENGTH=88 + + isort \ + --overwrite-in-place \ + --profile black \ + -j `nproc` \ + --line-length $LINE_LENGTH \ + --python-version auto \ + $DIRECTORY + + black \ + --line-length $LINE_LENGTH \ + --required-version 22.1.0 \ + --target-version py38 \ + --safe \ + $DIRECTORY +} + +function help() { + echo "usage: format.sh " +} + +if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then + help + exit 0 +fi + +main "$1" + -- 2.30.2