Created
February 19, 2014 17:14
-
-
Save cowlicks/9096656 to your computer and use it in GitHub Desktop.
pep0263 checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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