diff --git a/tools/pyflakes.sh b/tools/pyflakes.sh index 596a0ad9bd5b7c81c11c044b2429d08e16a7c1ca..16b2fe9157ab75c3d715c5dde6cd86080af96e0d 100755 --- a/tools/pyflakes.sh +++ b/tools/pyflakes.sh @@ -5,13 +5,9 @@ err=0 cd $(dirname $0)/.. -PY3MODS=$(grep -v '^#' ./tools/py3-compatible.modules|tr '\n' '|'|sed 's/|$//') - MODULE_FILES=$(git ls-files modules|grep '\.py$') -MODULE_FILES3=$(printf "%s\n" $MODULE_FILES|grep -E -w "^modules/(${PY3MODS})") PYFILES=$(git ls-files | grep '^scripts\|\.py$'|grep -v boilerplate_data|grep -v stable_backport_data|grep -v '^modules'|grep -v '^contrib') -PYFILES3="$PYFILES $MODULE_FILES3" PYFILES="$PYFILES $MODULE_FILES" grep -n 'class [^( ]\+:$' ${PYFILES} && echo 'Error: old class style found, always inherit object' && err=3 grep -n '[[:space:]]$' ${PYFILES} && echo 'Error: tabs or trailing whitespace found, remove them' && err=4 @@ -23,12 +19,12 @@ grep -Fn ".has_key" ${PYFILES} && echo 'Error: Deprecated, use operator "in"' && grep -Fn "os.isatty" ${PYFILES} && echo 'Error: Use stream.isatty() instead of os.isatty(stream.fileno())' && err=10 grep -Fn "raise StopIteration" ${PYFILES} && echo 'Error: PEP 479' && err=11 -grep -nE "\.iter(keys|values|items)\(\)" ${PYFILES3} | grep -Fv "six.iter" && echo 'Error: iterkeys/itervalues/iteritems is forbidden' && err=12 +grep -nE "\.iter(keys|values|items)\(\)" ${PYFILES} | grep -Fv "six.iter" && echo 'Error: iterkeys/itervalues/iteritems is forbidden' && err=12 grep -nE "^ *print(\(| )" ${MODULE_FILES} && echo 'Error: Use of print in modules is forbidden, use logger instead' && err=20 -grep -n xrange ${MODULE_FILES3} && echo 'Error: xrange is forbidden' && err=21 -grep -nE "from (urllib|urlparse) import" ${MODULE_FILES3} && echo 'Error: python2 urllib is forbidden' && err=22 -grep -nE "^import (urllib|urlparse)$" ${MODULE_FILES3} && echo 'Error: python2 urllib is forbidden' && err=22 +grep -n xrange ${MODULE_FILES} && echo 'Error: xrange is forbidden' && err=21 +grep -nE "from (urllib|urlparse) import" ${MODULE_FILES} && echo 'Error: python2 urllib is forbidden' && err=22 +grep -nE "^import (urllib|urlparse)$" ${MODULE_FILES} && echo 'Error: python2 urllib is forbidden' && err=22 grep -nE "HEADLESS[[:space:]]*=[[:space:]]*False" ${MODULE_FILES} && echo 'Error: HEADLESS must be set back to True' && err=23 if [ ${VER} -eq 2 ] @@ -61,7 +57,7 @@ then err=1 fi if [ ${err} -ne 1 ]; then - $PYTHON3 -m ${FLAKER3} ${OPT3} ${PYFILES3} || exit 33 + $PYTHON3 -m ${FLAKER3} ${OPT3} ${PYFILES} || exit 33 fi fi