Skip to content

Instantly share code, notes, and snippets.

@benman1
Last active July 8, 2018 19:09
Show Gist options
  • Save benman1/0bd78b473e7fd40e78a710fbb40a68f6 to your computer and use it in GitHub Desktop.
Save benman1/0bd78b473e7fd40e78a710fbb40a68f6 to your computer and use it in GitHub Desktop.
Fix a python repo that's completely out of date and badly formatted
#!/bin/sh
find . -name '*.py' -exec dos2unix {} \;
find . -name '*.py' -exec 2to3 -w {} \;
find . -name '*.py' -exec autopep8 --in-place --aggressive --aggressive {} \;
find . -name '*.py' -exec docformatter --in-place {} \;
isort -rc --atomic .
find . -name '*.py' -exec vim -c '%s/except \(.*\), e:/except \1 as e:/' {} -c 'wq' \;
find . -name '*.py' -exec autoflake --in-place --remove-unused-variables {} \;
find . -name '*.py' -exec vim -c '%s/xrange/range/' {} -c 'wq' \;
# also check unicode, ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment