diff options
Diffstat (limited to 'contrib/scripts/lint/lint-python.sh')
-rwxr-xr-x | contrib/scripts/lint/lint-python.sh | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/contrib/scripts/lint/lint-python.sh b/contrib/scripts/lint/lint-python.sh new file mode 100755 index 000000000..0e46719ff --- /dev/null +++ b/contrib/scripts/lint/lint-python.sh | |||
@@ -0,0 +1,79 @@ | |||
1 | #!/bin/sh | ||
2 | # check python style (and 2 to 3 migration) | ||
3 | # | ||
4 | # behold, the worst lowest effort shell script | ||
5 | # ...given that we have more generic checking | ||
6 | # for executables in other scripts already | ||
7 | |||
8 | existence() | ||
9 | { | ||
10 | command -v "$1" >/dev/null 2>&1 | ||
11 | } | ||
12 | |||
13 | # It is assumed that you are in 'lint'. | ||
14 | LOGFILE="python-lint.log" | ||
15 | |||
16 | # invoke from root of source! | ||
17 | if [ $(basename $(pwd)) = "scripts" ] | ||
18 | then | ||
19 | return 1 | ||
20 | else | ||
21 | if [ -e "${LOGFILE}" ] | ||
22 | then | ||
23 | rm ${LOGFILE} | ||
24 | fi | ||
25 | |||
26 | if existence python; | ||
27 | then | ||
28 | python --version >> ${LOGFILE} | ||
29 | fi | ||
30 | |||
31 | if existence python2; | ||
32 | then | ||
33 | python2 --version >> ${LOGFILE} | ||
34 | fi | ||
35 | |||
36 | if existence python3; | ||
37 | then | ||
38 | python3 --version >> ${LOGFILE} | ||
39 | fi | ||
40 | |||
41 | if existence python3.7; | ||
42 | then | ||
43 | python3.7 --version >> ${LOGFILE} | ||
44 | fi | ||
45 | |||
46 | if existence flake8; | ||
47 | then | ||
48 | echo >> ${LOGFILE} | ||
49 | echo "flake8:" >> ${LOGFILE} | ||
50 | echo >> ${LOGFILE} | ||
51 | flake8 >> ${LOGFILE} | ||
52 | fi | ||
53 | |||
54 | if existence flake8-3.7; | ||
55 | then | ||
56 | echo >> ${LOGFILE} | ||
57 | echo "flake8:" >> ${LOGFILE} | ||
58 | echo >> ${LOGFILE} | ||
59 | flake8-3.7 >> ${LOGFILE} | ||
60 | fi | ||
61 | |||
62 | if existence 2to3; | ||
63 | then | ||
64 | echo >> ${LOGFILE} | ||
65 | echo "2to3" >> ${LOGFILE} | ||
66 | echo >> ${LOGFILE} | ||
67 | 2to3 -v -d . >> ${LOGFILE} | ||
68 | 2to3 -v -p . >> ${LOGFILE} | ||
69 | fi | ||
70 | |||
71 | if existence 2to3-3.7; | ||
72 | then | ||
73 | echo >> ${LOGFILE} | ||
74 | echo "2to3" >> ${LOGFILE} | ||
75 | echo >> ${LOGFILE} | ||
76 | 2to3-3.7 -v -d . >> ${LOGFILE} | ||
77 | 2to3-3.7 -v -p . >> ${LOGFILE} | ||
78 | fi | ||
79 | fi | ||