Skip to content

Instantly share code, notes, and snippets.

@prologic
Created February 9, 2015 05:38
Show Gist options
  • Save prologic/273be3d876da39ba4d63 to your computer and use it in GitHub Desktop.
Save prologic/273be3d876da39ba4d63 to your computer and use it in GitHub Desktop.
created by github.com/tr3buchet/gister
#!/bin/bash
# Tool: fix-codebase.sh
# Author: James Mills, prologic at shortcircuit dot net dot au
# Date: 09 February 2015
# Fix a Python codebase that may contain several common issues:
# - PEP8 violations
# - Tabs instead of spaces
# - CRLF (Windows) style line endings instead of LF (UNix) style line endings
#
# This tool just assumes the codebase violates all three and
# blatently runs do2unix, autopep8 and a sed (for tabs) on every
# file regardless of if there are no issues or not.
#
# This *should* be safe on any codebase as these tools are quite robust.
find . -type f -name "*.py" -print0 | xargs -0 -n 1 -P 8 dos2unix
find . -type f -name "*.py" -print0 | xargs -0 -n 1 -P 8 autopep8 -i
find . -type f -name "*.py" -print0 | xargs -0 -n 1 -P 8 sed -i -e 's/ / /g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment