Skip to content

Instantly share code, notes, and snippets.

@rmcauley
Created July 31, 2017 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmcauley/2913cd4965b56700323f83ee8bbbf5c2 to your computer and use it in GitHub Desktop.
Save rmcauley/2913cd4965b56700323f83ee8bbbf5c2 to your computer and use it in GitHub Desktop.
failed="no"
find . -name '*.py' -not -path "./.env/*" -not -path "./node_modules/*" -print0 |
while IFS= read -r -d $'\0' line; do
if [ -s $line ]; then
grep -L "from __future__ import unicode_literals" $line
if [ "$?" -ne "0" ]; then
failed="yes"
fi
fi
done
if [ $failed != "no" ]; then
echo
echo "The above files are not UTF-8 safe. Please add this to the top of the files:"
echo
echo "# -*- coding: utf-8 -*-"
echo
echo "from __future__ import unicode_literals"
echo
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment