Skip to content

Commit

Permalink
checkstyle: Warn when not all __future__s are there
Browse files Browse the repository at this point in the history
  • Loading branch information
embolalia committed Mar 28, 2015
1 parent 85ab0a1 commit 91e9e92
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions checkstyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,29 @@ if $fail_py3_unicode; then
exit_code=1
fi

fail_unicode_literals=false
for file in $files; do
if ! grep -L 'from __future__ import unicode_literals' $file; then
fail_unicode_literals=true
check_future () {
fail_unicode_literals=false
for file in $files; do
if ! grep -L "from __future__ import $1" $file; then
fail_unicode_literals=true
fi
done
if $fail_unicode_literals; then
if $2; then
echo "ERROR: Above files do not have $1 import."
exit_code=1
else
echo "WARNING: Above files do not have $1 import."
fi
fi
}
for mandatory in unicode_literals
do
check_future $mandatory true
done
for optional in division print_function absolute_import
do
check_future $optional false
done
if $fail_unicode_literals; then
echo "ERROR: Above files do not have unicode_literals import."
exit_code=1
fi

exit $exit_code

0 comments on commit 91e9e92

Please sign in to comment.