Skip to content

Instantly share code, notes, and snippets.

@cowlicks
Created February 19, 2014 17:14
Show Gist options
  • Select an option

  • Save cowlicks/9096656 to your computer and use it in GitHub Desktop.

Select an option

Save cowlicks/9096656 to your computer and use it in GitHub Desktop.
pep0263 checker
#!/usr/bin/env bash
# Return a list of files which need to have the pep0263 encoding
# statement added.
PATTERN='coding: utf-8' # The pattern for your encoding
FILES=`find . -name "*.py"` # The files you want to check
for i in $FILES; do
# Get the line numbers matching the pattern
LINE=`grep -nr "$PATTERN" "$i" | cut -d : -f 2`
# if not on line 1 or 2:
if ! [[ $LINE -eq 1 ]] || [[ $LINE -eq 2 ]]; then
# print the files that need the encoding
echo $i;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment