Skip to content

Instantly share code, notes, and snippets.

@seanmckaybeck
Last active August 29, 2015 14:05
Show Gist options
  • Save seanmckaybeck/f7ae231e85d74b62e049 to your computer and use it in GitHub Desktop.
Save seanmckaybeck/f7ae231e85d74b62e049 to your computer and use it in GitHub Desktop.
A pre-commit hook for checking PEP 8 compliance
import os
def some_function(a, b):
return a*b
if __name__ == '__main__':
print some_function(2,
3)
'''
A crappy script
'''
import os
def some_func(num1, num2):
'''
a crappy function
'''
return num1 * num2
if __name__ == '__main__':
print os.getcwd()
print some_func(2, 3)
#!/bin/bash
for f in *.py; do
echo $f
OUTPUT=`pep8 $f`
if [ -n "$OUTPUT" ]; then
echo "pep8 found errors!!"
echo $OUTPUT
exit 1
fi
pattern="[0-9]+\.[0-9]+/10"
output=`pylint $f`
score=`echo $output | grep -oP $pattern`
pattern="[0-9]+\.[0-9]+"
parsed=`echo $score | grep -oP $pattern`
SCORE=""
for word in $parsed
do
SCORE=$word
break
done
# echo $SCORE
concat=" > 9"
compare=$SCORE$concat
result=`echo $compare | bc`
if [ "$result" -eq "0" ]; then
echo "pylint failed for $f"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment