From ffb8f841be5224730b45a5d1e9b4674f4039c989 Mon Sep 17 00:00:00 2001 From: lars Date: Fri, 12 Jun 2009 01:40:26 +0000 Subject: [PATCH] * change default indentation (as checked by pylint) from tab to spaces * changed default behaviour of pylint wrapper script: check _everything_ if no parameters are given --- bin/do_pylint.sh | 65 ++++++++++++++++++++++++++++++++++-------------- src/pylintrc | 2 +- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/bin/do_pylint.sh b/bin/do_pylint.sh index d4991d9..eb8cedb 100755 --- a/bin/do_pylint.sh +++ b/bin/do_pylint.sh @@ -2,34 +2,63 @@ # # set some environmental variables for pylint and run it # +# you may specify single files or modules as parameters +# +# no parameters: check all python files +# + +set -eu PROJ_DIR=$(dirname "$0")/.. PROJ_DIR=$(cd "$PROJ_DIR"; pwd) -PYLINTRC=$PROJ_DIR/src/pylintrc -PYTHONPATH=$PROJ_DIR/src +# implicitely used by pylint +export PYLINTRC=$PROJ_DIR/src/pylintrc +BASIC_PYTHONPATH=$PROJ_DIR/src -check_for_filename() -{ + +# check for the pylint program +[ ! -x /usr/bin/pylint ] && echo >&2 "please run \"apt-get install pylint\" first" && exit 1 + + +is_filename() { + echo "$1" | grep -q "\.py$" && test -e "$1" && return 0 + return 1 +} + + +get_pythonpath() { # maybe the argument is a file instead of a module name - if echo "$1" | grep -q "\.py$" && test -e "$1" - then local FILE_DIR=$(dirname "$1") - local MODULE=$(basename "${1%.py}") - ARGS="${ARGS} ${MODULE}" - PYTHONPATH="${PYTHONPATH}:${FILE_DIR}" - else ARGS="${ARGS} ${1}" + is_filename "$1" && echo -n ":$(dirname "$1")" +} + + +get_module() { + if is_filename "$1"; then + echo -n "$(basename "${1%.py}")" + else + echo -n "$1" fi } -while test $# -gt 0 - do check_for_filename "$1" - shift - done -export PYTHONPATH -export PYLINTRC +run_pylint() { + local new_pythonpath="${BASIC_PYTHONPATH}$(get_pythonpath "$1")" + local arg="$(get_module "$1")" + PYTHONPATH="$new_pythonpath" pylint "$arg" +} -[ ! -x /usr/bin/pylint ] && echo >&2 "please run \"apt-get install pylint\" first" && exit 1 -pylint $ARGS +# check the complete (basic) package and the plugins, if no arguments were given +if test $# -eq 0; then + run_pylint cryptobox + find "$PROJ_DIR/plugins" -type f -name \*.py | while read fname; do + run_pylint "$fname" + done + else + while test $# -gt 0; do + run_pylint "$1" + shift + done + fi diff --git a/src/pylintrc b/src/pylintrc index bdcf546..ca1e83a 100644 --- a/src/pylintrc +++ b/src/pylintrc @@ -35,7 +35,7 @@ max-module-lines=1000 # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 # tab). -indent-string='\t' +indent-string=' ' [MISCELLANEOUS]