diff options
-rwxr-xr-x | contrib/scripts/lint-python.sh | 82 |
1 files changed, 67 insertions, 15 deletions
diff --git a/contrib/scripts/lint-python.sh b/contrib/scripts/lint-python.sh index 9f7e0462d..3325460f6 100755 --- a/contrib/scripts/lint-python.sh +++ b/contrib/scripts/lint-python.sh | |||
@@ -1,24 +1,76 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # check python style (and 2 to 3 migration) | 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 | ||
3 | 7 | ||
4 | rm python-lint.log | 8 | existence() |
9 | { | ||
10 | command -v "$1" >/dev/null 2>&1 | ||
11 | } | ||
5 | 12 | ||
6 | if [ -e "python" ] | 13 | # invoke from root of source! |
14 | if [ $(basename $(pwd)) = "scripts" ] | ||
7 | then | 15 | then |
8 | python --version >> python-lint.log | 16 | return 1 |
9 | fi | 17 | else |
18 | if [ -e "python-lint.log" ] | ||
19 | then | ||
20 | rm "python-lint.log" | ||
21 | fi | ||
10 | 22 | ||
11 | if [ -e "python2" ] | 23 | if existence python; |
12 | then | 24 | then |
13 | python2 --version >> python-lint.log | 25 | python --version >> python-lint.log |
14 | fi | 26 | fi |
15 | 27 | ||
16 | if [ -e "python3" ] | 28 | if existence python2; |
17 | then | 29 | then |
18 | python3 --version >> python-lint.log | 30 | python2 --version >> python-lint.log |
19 | fi | 31 | fi |
20 | 32 | ||
21 | flake8 >> python-lint.log | 33 | if existence python3; |
34 | then | ||
35 | python3 --version >> python-lint.log | ||
36 | fi | ||
22 | 37 | ||
23 | 2to3 -v -d . >> python-lint.log | 38 | if existence python3.7; |
24 | 2to3 -v -p . >> python-lint.log | 39 | then |
40 | python3.7 --version >> python-lint.log | ||
41 | fi | ||
42 | |||
43 | if existence flake8; | ||
44 | then | ||
45 | echo >> python-lint.log | ||
46 | echo "flake8:" >> python-lint.log | ||
47 | echo >> python-lint.log | ||
48 | flake8 >> python-lint.log | ||
49 | fi | ||
50 | |||
51 | if existence flake8-3.7; | ||
52 | then | ||
53 | echo >> python-lint.log | ||
54 | echo "flake8:" >> python-lint.log | ||
55 | echo >> python-lint.log | ||
56 | flake8-3.7 >> python-lint.log | ||
57 | fi | ||
58 | |||
59 | if existence 2to3; | ||
60 | then | ||
61 | echo >> python-lint.log | ||
62 | echo "2to3" >> python-lint.log | ||
63 | echo >> python-lint.log | ||
64 | 2to3 -v -d . >> python-lint.log | ||
65 | 2to3 -v -p . >> python-lint.log | ||
66 | fi | ||
67 | |||
68 | if existence 2to3-3.7; | ||
69 | then | ||
70 | echo >> python-lint.log | ||
71 | echo "2to3" >> python-lint.log | ||
72 | echo >> python-lint.log | ||
73 | 2to3-3.7 -v -d . >> python-lint.log | ||
74 | 2to3-3.7 -v -p . >> python-lint.log | ||
75 | fi | ||
76 | fi | ||