Run indent checks in diskimage_builder/lib

Scripts have moved from bin/ to diskimage_builder/lib (and are not
executable, since they are called from dib).  Add a match so we run
checkers over those files.

Clarify the situation with .py files while we're here.

Change-Id: I8a1ef4b00a185b83c8b1f29c563b85e78bc233ca
This commit is contained in:
Ian Wienand 2017-03-08 11:54:16 +11:00
parent 866a06f92d
commit c8206d1ab6

View File

@ -22,6 +22,7 @@ set -eu
set -o pipefail set -o pipefail
ELEMENTS_DIR=diskimage_builder/elements ELEMENTS_DIR=diskimage_builder/elements
LIB_DIR=diskimage_builder/lib
parse_exclusions() { parse_exclusions() {
# Per-file exclusions # Per-file exclusions
@ -69,13 +70,15 @@ echo "Running dib-lint in $(pwd)"
rc=0 rc=0
TMPDIR=$(mktemp -d /tmp/tmp.XXXXXXXXXX) TMPDIR=$(mktemp -d /tmp/tmp.XXXXXXXXXX)
trap "rm -rf $TMPDIR" EXIT trap "rm -rf $TMPDIR" EXIT
for i in $(find $ELEMENTS_DIR -type f \
-not -name \*~ \ # note .py files are run through flake8 directly in tox.ini
-not -name \#\*\# \ for i in $(find $ELEMENTS_DIR -type f \
-not -name \*.orig \ -not -name \*~ \
-not -name \*.rst \ -not -name \#\*\# \
-not -name \*.yaml \ -not -name \*.orig \
-not -name \*.py \ -not -name \*.rst \
-not -name \*.yaml \
-not -name \*.py \
-not -name \*.pyc); do -not -name \*.pyc); do
echo "Checking $i" echo "Checking $i"
@ -89,10 +92,10 @@ for i in $(find $ELEMENTS_DIR -type f \
error "$i is not executable" error "$i is not executable"
fi fi
# run flake8 over python files. note our "dib-python" # run flake8 over python files that don't have .py. Note our
# interpreter can confuse the magic matching being done in # "dib-python" interpreter can confuse the magic matching
# "file" and make it think the file is not python; # being done in "file" and make it think the file is not
# special-case it. # python; special-case it.
if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]] || \ if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]] || \
[[ $firstline =~ "dib-python" ]]; then [[ $firstline =~ "dib-python" ]]; then
flake8 $i || error "$i failed flake8" flake8 $i || error "$i failed flake8"
@ -210,7 +213,8 @@ done
echo "Checking indents..." echo "Checking indents..."
for i in $(find bin $ELEMENTS_DIR -type f -and -name '*.rst' -or -type f -executable); do for i in $(find $ELEMENTS_DIR -type f -and -name '*.rst' -or -type f -executable) \
$(find $LIB_DIR -type f); do
# Check for tab indentation # Check for tab indentation
if ! excluded tabindent; then if ! excluded tabindent; then
if grep -q $'^ *\t' ${i}; then if grep -q $'^ *\t' ${i}; then