1#!/bin/bash 2# Copyright 2021 The gRPC Authors 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16set -ex 17 18ACTION=${1:---overwrite-in-place} 19[[ $ACTION == '--overwrite-in-place' ]] || [[ $ACTION == '--diff' ]] 20 21if [[ $ACTION == '--diff' ]]; then 22 ACTION="--diff --check" 23fi 24 25# Change to root 26cd "$(dirname "${0}")/../.." 27 28DIRS=( 29 'examples/python' 30 'src/python' 31 'test' 32 'tools' 33 'setup.py' 34) 35 36VIRTUALENV=isort_virtual_environment 37 38python3 -m virtualenv $VIRTUALENV 39PYTHON=${VIRTUALENV}/bin/python 40"$PYTHON" -m pip install isort==5.9.2 41 42$PYTHON -m isort $ACTION --settings-path=black.toml --dont-follow-links "${DIRS[@]}" 43