Skip to content

Commit

Permalink
Merge pull request the-ethan-hunt#132 from Man-Jain/master
Browse files Browse the repository at this point in the history
Added pylinter.sh and setup.cfg
  • Loading branch information
the-ethan-hunt authored Jul 18, 2018
2 parents 5581bdf + 0dafac8 commit 0500c25
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pylinter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

directories="linux MacOS windows"
pass=0
fail=0

function prepare_venv() {
VIRTUALENV=$(which venv)
if [ $? -eq 1 ]; then

VIRTUALENV=$(which venv-3)
fi

${VIRTUALENV} python3 -m venv mybenjienv && source mybenjienv/bin/activate && python3 "$(which pip3)" install pycodestyle
}


echo "----------------------------------------------------"
echo "Running Python Linter against following directories:"
echo "$directories"
echo "----------------------------------------------------"
echo

[ "$NOVENV" == "1" ] || prepare_venv || exit 1

# checks for the whole directories
for directory in $directories
do
files=$(find "$directory" -path "$directory/venv" -prune -o -name '*.py' -print)

for source in $files
do
echo "$source"
pycodestyle "$source"
if [ $? -eq 0 ]
then
echo " Pass"
let "pass++"
else
echo " Fail"
let "fail++"
fi
done
done

$(deactivate && rm -rf mybenjienv/)

if [ $fail -eq 0 ]
then
echo "All checks passed for $pass source files"
else
let total=$pass+$fail
echo "Linter fail, $fail source files out of $total source files need to be fixed"
exit 1
fi
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pycodestyle]
ignore = W504
max-line-length = 80

0 comments on commit 0500c25

Please sign in to comment.