From 8a3f9a7baedf582790aee90e21ae70897f9715a6 Mon Sep 17 00:00:00 2001 From: Uwe Jugel Date: Tue, 18 Apr 2017 19:41:15 +0200 Subject: [PATCH 1/3] added module option, use more common zero test, show module name in log --- sdks/python/run_pylint.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sdks/python/run_pylint.sh b/sdks/python/run_pylint.sh index 80cbe6ef314c..c18341e65579 100755 --- a/sdks/python/run_pylint.sh +++ b/sdks/python/run_pylint.sh @@ -23,7 +23,7 @@ # # The exit-code of the script indicates success or a failure. -set -e +set -o errexit set -o pipefail # Following generated files are excluded from lint checks. @@ -39,14 +39,19 @@ EXCLUDED_GENERATED_FILES=( FILES_TO_IGNORE="" for file in "${EXCLUDED_GENERATED_FILES[@]}"; do - if [[ $FILES_TO_IGNORE ]]; then - FILES_TO_IGNORE="$FILES_TO_IGNORE, " + if test -z "$FILES_TO_IGNORE" + then FILES_TO_IGNORE="$(basename $file)" + else FILES_TO_IGNORE="$FILES_TO_IGNORE, $(basename $file)" fi - FILES_TO_IGNORE="$FILES_TO_IGNORE$(basename $file)" done echo "Skipping lint for generated files: $FILES_TO_IGNORE" -echo "Running pylint:" -pylint apache_beam --ignore-patterns="$FILES_TO_IGNORE" -echo "Running pep8:" -pep8 apache_beam --exclude="$FILES_TO_IGNORE" +if test $# -gt 0 +then MODULE="$@" +else MODULE=apache_beam +fi + +echo "Running pylint for module $MODULE:" +pylint $MODULE --ignore-patterns="$FILES_TO_IGNORE" +echo "Running pep8 for module $MODULE:" +pep8 $MODULE --exclude="$FILES_TO_IGNORE" From a98fe93c3b2b1d3c35b2240ea5d3e1001e0554ad Mon Sep 17 00:00:00 2001 From: Uwe Jugel Date: Tue, 18 Apr 2017 21:28:33 +0200 Subject: [PATCH 2/3] fixed indentation nits --- sdks/python/run_pylint.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdks/python/run_pylint.sh b/sdks/python/run_pylint.sh index c18341e65579..6a12a982b117 100755 --- a/sdks/python/run_pylint.sh +++ b/sdks/python/run_pylint.sh @@ -40,15 +40,15 @@ EXCLUDED_GENERATED_FILES=( FILES_TO_IGNORE="" for file in "${EXCLUDED_GENERATED_FILES[@]}"; do if test -z "$FILES_TO_IGNORE" - then FILES_TO_IGNORE="$(basename $file)" - else FILES_TO_IGNORE="$FILES_TO_IGNORE, $(basename $file)" + then FILES_TO_IGNORE="$(basename $file)" + else FILES_TO_IGNORE="$FILES_TO_IGNORE, $(basename $file)" fi done echo "Skipping lint for generated files: $FILES_TO_IGNORE" if test $# -gt 0 -then MODULE="$@" -else MODULE=apache_beam + then MODULE="$@" + else MODULE=apache_beam fi echo "Running pylint for module $MODULE:" From 926eb082e799e75bfdb15d566db3c3c419e07119 Mon Sep 17 00:00:00 2001 From: Uwe Jugel Date: Wed, 19 Apr 2017 17:08:16 +0200 Subject: [PATCH 3/3] added usage info --- sdks/python/run_pylint.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sdks/python/run_pylint.sh b/sdks/python/run_pylint.sh index 6a12a982b117..f733a79fa6be 100755 --- a/sdks/python/run_pylint.sh +++ b/sdks/python/run_pylint.sh @@ -26,6 +26,17 @@ set -o errexit set -o pipefail +MODULE=apache_beam + +usage(){ echo "Usage: $0 [MODULE|--help] # The default MODULE is $MODULE"; } + +if test $# -gt 0; then + case "$@" in + --help) usage; exit 1;; + *) MODULE="$@";; + esac +fi + # Following generated files are excluded from lint checks. EXCLUDED_GENERATED_FILES=( "apache_beam/io/gcp/internal/clients/bigquery/bigquery_v2_client.py" @@ -46,11 +57,6 @@ for file in "${EXCLUDED_GENERATED_FILES[@]}"; do done echo "Skipping lint for generated files: $FILES_TO_IGNORE" -if test $# -gt 0 - then MODULE="$@" - else MODULE=apache_beam -fi - echo "Running pylint for module $MODULE:" pylint $MODULE --ignore-patterns="$FILES_TO_IGNORE" echo "Running pep8 for module $MODULE:"