* 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 changed files with 48 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue