Skip to content

Instantly share code, notes, and snippets.

@perrygeo
Created February 24, 2012 19:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perrygeo/1903033 to your computer and use it in GitHub Desktop.
Save perrygeo/1903033 to your computer and use it in GitHub Desktop.
Sed scripts to fix blank lines and whitespace; helps code comply with PEP8
# Removes whitespace chars from blank lines
pep8 -r --select=W293 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i 's/^[ \r\t]*$//'
# Removes trailing blank lines from files
pep8 -r --select=W391 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}'
# Squashes consecutive blanks lines into one
pep8 -r --select=E303 -q --filename=*.py /usr/local/src/madrona/madrona/ | xargs sed -i '/./,/^$/!d'
# confirm
pep8 -r --select=W391,W293,E303 -q --filename=*.py /usr/local/src/madrona/madrona/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment