67 lines
1.3 KiB
Bash
Executable file
67 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Set some environmental variables for pylint and run it.
|
|
#
|
|
# You may specify single files or modules as parameters.
|
|
#
|
|
# If no parameters are given, all python files are checked.
|
|
#
|
|
|
|
set -eu
|
|
|
|
PROJ_DIR=$(dirname "$0")/..
|
|
PROJ_DIR=$(cd "$PROJ_DIR"; pwd)
|
|
|
|
# implicitely used by pylint
|
|
export PYLINTRC=$PROJ_DIR/src/pylintrc
|
|
BASIC_PYTHONPATH=$PROJ_DIR/src
|
|
|
|
|
|
# check for the pylint program
|
|
if [ ! -x /usr/bin/pylint ] ; then
|
|
echo >&2 "/usr/bin/pylint not found"
|
|
echo >&2 "please run \"apt-get install pylint\" first"
|
|
exit 1
|
|
fi
|
|
|
|
|
|
is_filename() {
|
|
[ "${1%.py}" != "$1" -a -e "$1" ]
|
|
}
|
|
|
|
|
|
get_pythonpath() {
|
|
# maybe the argument is a file instead of a module name
|
|
is_filename "$1" && echo -n ":$(dirname "$1")"
|
|
}
|
|
|
|
|
|
get_module() {
|
|
if is_filename "$1"; then
|
|
echo -n "$(basename "$1" .py)"
|
|
else
|
|
echo -n "$1"
|
|
fi
|
|
}
|
|
|
|
|
|
run_pylint() {
|
|
local new_pythonpath="${BASIC_PYTHONPATH}$(get_pythonpath "$1")"
|
|
local arg="$(get_module "$1")"
|
|
PYTHONPATH="$new_pythonpath" pylint "$arg"
|
|
}
|
|
|
|
|
|
|
|
# If no arguments were given, check the complete (basic) package and
|
|
# the plugin.
|
|
if [ $# -eq 0 ] ; then
|
|
run_pylint cryptobox
|
|
find "$PROJ_DIR/plugins" -type f -name \*.py -print0 | xargs -0 run_pylint
|
|
else
|
|
for name in "$@" ; do
|
|
run_pylint "$name"
|
|
done
|
|
fi
|
|
|