* 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
This commit is contained in:
parent
fe0a062bf6
commit
ffb8f841be
|
@ -2,34 +2,63 @@
|
||||||
#
|
#
|
||||||
# set some environmental variables for pylint and run it
|
# 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=$(dirname "$0")/..
|
||||||
PROJ_DIR=$(cd "$PROJ_DIR"; pwd)
|
PROJ_DIR=$(cd "$PROJ_DIR"; pwd)
|
||||||
|
|
||||||
PYLINTRC=$PROJ_DIR/src/pylintrc
|
# implicitely used by pylint
|
||||||
PYTHONPATH=$PROJ_DIR/src
|
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
|
# maybe the argument is a file instead of a module name
|
||||||
if echo "$1" | grep -q "\.py$" && test -e "$1"
|
is_filename "$1" && echo -n ":$(dirname "$1")"
|
||||||
then local FILE_DIR=$(dirname "$1")
|
}
|
||||||
local MODULE=$(basename "${1%.py}")
|
|
||||||
ARGS="${ARGS} ${MODULE}"
|
|
||||||
PYTHONPATH="${PYTHONPATH}:${FILE_DIR}"
|
get_module() {
|
||||||
else ARGS="${ARGS} ${1}"
|
if is_filename "$1"; then
|
||||||
|
echo -n "$(basename "${1%.py}")"
|
||||||
|
else
|
||||||
|
echo -n "$1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
while test $# -gt 0
|
|
||||||
do check_for_filename "$1"
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
export PYTHONPATH
|
run_pylint() {
|
||||||
export PYLINTRC
|
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
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ max-module-lines=1000
|
||||||
|
|
||||||
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
|
||||||
# tab).
|
# tab).
|
||||||
indent-string='\t'
|
indent-string=' '
|
||||||
|
|
||||||
|
|
||||||
[MISCELLANEOUS]
|
[MISCELLANEOUS]
|
||||||
|
|
Loading…
Reference in New Issue