Skip to content

Instantly share code, notes, and snippets.

@NichtJens
Created June 25, 2015 12:51
Show Gist options
  • Save NichtJens/89137829a1d2acf64ec6 to your computer and use it in GitHub Desktop.
Save NichtJens/89137829a1d2acf64ec6 to your computer and use it in GitHub Desktop.
Create a temporary autopep8'ed version of a Python script and diff(meld/diffuse) it with the original
#!/bin/bash
set -o nounset
set -o errexit
if [ "$#" == "0" ]; then
echo "usage: $0 [autopep8 options] input.py"
exit 1
fi
ap8ed=$(mktemp)
input=$@
infile=( $( for i in ${input[@]}; do echo $i; done | grep .py$ ) )
differs="diff meld diffuse"
for d in $differs; do
command -v $d >/dev/null && differ=$d
done
autopep8 --max-line-length=999 $input > "$ap8ed"
echo "$differ - original: $infile vs. autopep8ed: $ap8ed"
"$differ" "$infile" "$ap8ed"
rm "$ap8ed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment