summaryrefslogtreecommitdiff
path: root/contrib/scripts/lint-python.sh
blob: cf737cae257777a2a7358777795e69981e0a1451 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
# check python style (and 2 to 3 migration)
#
# behold, the worst lowest effort shell script
# ...given that we have more generic checking
# for executables in other scripts already

existence()
{
    command -v "$1" >/dev/null 2>&1
}

LOGFILE="lint/python-lint.log"

# invoke from root of source!
if [ $(basename $(pwd)) = "scripts" ]
then
   return 1
else
    if [ -e "${LOGFILE}" ]
    then
        rm ${LOGFILE}
    fi

    if existence python;
    then
        python --version >> ${LOGFILE}
    fi

    if existence python2;
    then
        python2 --version >> ${LOGFILE}
    fi

    if existence python3;
    then
        python3 --version >> ${LOGFILE}
    fi

    if existence python3.7;
    then
        python3.7 --version >> ${LOGFILE}
    fi

    if existence flake8;
    then
        echo >> ${LOGFILE}
        echo "flake8:" >> ${LOGFILE}
        echo >> ${LOGFILE}
        flake8 >> ${LOGFILE}
    fi

    if existence flake8-3.7;
    then
        echo >> ${LOGFILE}
        echo "flake8:" >> ${LOGFILE}
        echo >> ${LOGFILE}
        flake8-3.7 >> ${LOGFILE}
    fi

    if existence 2to3;
    then
        echo >> ${LOGFILE}
        echo "2to3" >> ${LOGFILE}
        echo >> ${LOGFILE}
        2to3 -v -d . >> ${LOGFILE}
        2to3 -v -p . >> ${LOGFILE}
    fi

    if existence 2to3-3.7;
    then
        echo >> ${LOGFILE}
        echo "2to3" >> ${LOGFILE}
        echo >> ${LOGFILE}
        2to3-3.7 -v -d . >> ${LOGFILE}
        2to3-3.7 -v -p . >> ${LOGFILE}
    fi
fi