added module option, use more common zero test, show module name in log
Project: http://git-wip-us.apache.org/repos/asf/beam/repo Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/28a2682b Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/28a2682b Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/28a2682b Branch: refs/heads/gearpump-runner Commit: 28a2682b4d1f63942f3c0e67458f5558c91c06a9 Parents: 6224556 Author: Uwe Jugel <[email protected]> Authored: Tue Apr 18 19:41:15 2017 +0200 Committer: Ahmet Altay <[email protected]> Committed: Wed Apr 19 16:45:57 2017 -0700 ---------------------------------------------------------------------- sdks/python/run_pylint.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/beam/blob/28a2682b/sdks/python/run_pylint.sh ---------------------------------------------------------------------- diff --git a/sdks/python/run_pylint.sh b/sdks/python/run_pylint.sh index 80cbe6e..f733a79 100755 --- a/sdks/python/run_pylint.sh +++ b/sdks/python/run_pylint.sh @@ -23,9 +23,20 @@ # # The exit-code of the script indicates success or a failure. -set -e +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" @@ -39,14 +50,14 @@ 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" +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"
