-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathcheck_python
executable file
·43 lines (43 loc) · 1.4 KB
/
check_python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
program="$0"
module="$1"
method="$2"
help1="Usage: \tcheck_python --pylint \t# all modules with pylint"
help2=" \tcheck_python --flake8 \t# all modules with flake8"
help3=" \tcheck_python --autopep8 \t# all modules with autopep8 -i"
help4=" \tcheck_python myprog.py \t# scan single program module only"
if [[ "$#" == 0 || "$module" == "-h" || "$module" == "--help" ]]; then
echo " "
echo -e $help1
echo -e $help2
echo -e $help3
echo -e $help4
echo " "
exit 4;
else
migs="migrations"
inits="__init__."
set="cfc_project.settings"
plug="--load-plugins=pylint_django"
if [[ "$module" == "--pylint" ]]; then
find . -iname "*.py" -exec "$program" {} --pylint \;
elif [[ "$module" == "--flake8" ]]; then
find . -iname "*.py" -exec "$program" {} --flake8 \;
elif [[ "$module" == "--autopep8" ]]; then
find . -iname "*.py" -exec "$program" {} --autopep8 \;
elif [[ ("$module" == *".py"*)
&& ("$module" != *"$migs"*)
&& ("$module" != *"$inits"*) ]]; then
echo "Check_python: $module"
if [[ "$method" == "--pylint" ]]; then
# DJANGO_SETTINGS_MODULE=$set pylint $plug "$module"
pylint "$module"
elif [[ "$method" == "--autopep8" ]]; then
autopep8 -i "$module"
else
flake8 "$module"
fi
else
echo "Python module $module -- skipped"
fi
fi