# check existence of file, ensure absoluteness of path
if [ "$#" -ne 1 ]; then
- echo "usage: lintplom FILEPATH"
+ echo "usage: lintplom TARGET"
echo ""
echo "arguments:"
- echo " FILEPATH - source file to run Python linters against"
+ echo " TARGET – what to run Python linters against: either an individual source file,"
+ echo " or a directory to scan for those (by their .py endings)"
exit 1
fi
# check existence of file, ensure absoluteness of path
TARGET="$1"
-if [ ! -f "$1" ]; then
- echo "Must provide valid file path as argument."
+if ! [ -f "$1" -o -d "$1" ]; then
+ echo "Must provide valid file or directory path as argument."
exit 1
fi
if [ $(echo "${TARGET}" | cut -c1) != '/' ]; then
fi
FILE_REQS=requirements.txt
DIR_REQS=
-cd "$(dirname ${TARGET})"
+if [ -d "${TARGET}" ]; then
+ cd "${TARGET}"
+else
+ cd "$(dirname ${TARGET})"
+fi
while true; do
if [ "$(pwd)" = "${HOME}" ]; then
break
# run actual tests
set +e
-echo "\n\n============================[ FLAKE results ]==================================\n"
-flake8 "${TARGET}"
-echo "\n\n============================[ PYLINT results ]=================================\n"
-pylint "${TARGET}"
-echo "\n\n============================[ MYPY results ]===================================\n"
-mypy "${TARGET}"
+for LINTER in flake8 pylint mypy; do
+ echo "\n=====[ ${LINTER} results ]=====\n"
+ if [ -d "${TARGET}" ]; then
+ for FILE in "${TARGET}"/*.py; do
+ ${LINTER} "${FILE}"
+ done
+ else
+ ${LINTER} "${TARGET}"
+ fi
+ echo ""
+done