Skip to content

Commit

Permalink
reorg
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche authored and Pierre Tardy committed Nov 7, 2013
1 parent 73c221b commit 2b27472
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
8 changes: 4 additions & 4 deletions common/style_check_and_fix.sh
Expand Up @@ -17,7 +17,7 @@ done
echo "======== Checking Import module convention in modified files ========"

RES=true
for filename in ${FILES[@]}; do
for filename in ${py_files[@]}; do
python common/fiximports.py "$filename"
if [[ $? != 0 ]]; then
echo "cannot fix imports of $filename"
Expand All @@ -36,7 +36,7 @@ if [[ -z `which autopep8` ]]; then
else
echo "============================== Auto pep8 =============================="

for filename in ${FILES[@]}; do
for filename in ${py_files[@]}; do
if [[ -f common/pep8rc ]]; then
LINEWIDTH=$(grep -E "max-line-length" common/pep8rc | sed 's/ //g' | cut -d'=' -f 2)
# even if we dont enforce errors, if they can be fixed automatically, thats better..
Expand All @@ -58,7 +58,7 @@ else
echo "=============================== Pep8 =================================="

if [[ -f common/pep8rc ]]; then
for filename in ${FILES[@]}; do
for filename in ${py_files[@]}; do
pep8 --config=common/pep8rc "$filename"
if [[ $? != 0 ]]; then
echo "pep8 issues"
Expand All @@ -76,7 +76,7 @@ else
echo "========================== Pylint =========================="

if [[ -f common/pylintrc ]]; then
for filename in ${FILES[@]}; do
for filename in ${py_files[@]}; do
pylint --rcfile=common/pylintrc --disable=R,line-too-long --enable=W0611 --output-format=text --report=no "$filename"
if [[ $? != 0 ]]; then
echo "pylint issues"
Expand Down
41 changes: 39 additions & 2 deletions common/validate.sh
Expand Up @@ -63,6 +63,16 @@ if ! git diff --no-ext-diff --quiet --exit-code; then
exit 1
fi

# get a list of changed files, used below; this uses a tempfile to work around
# shell behavior when piping to 'while'
tempfile=$(mktemp)
trap 'rm -f ${tempfile}' 1 2 3 15
git diff --name-only $REVRANGE | grep '\.py$' | grep -v '\(^master/\(contrib\|docs\)\|/setup\.py\)' > ${tempfile}
py_files=()
while read line; do
py_files+=($line)
done < ${tempfile}

echo "${MAGENTA}Validating the following commits:${NORM}"
git log "$REVRANGE" --pretty=oneline || exit 1

Expand All @@ -78,8 +88,35 @@ check_relnotes || warning "$REVRANGE does not add release notes"
status "running pyflakes"
pyflakes master/buildbot slave/buildslave || not_ok "failed pyflakes"

status "check and fix style issues"
git diff --name-only $REVRANGE | common/style_check_and_fix.sh || not_ok "style issues"
status "checking import module convention in modified files"
RES=true
for filename in ${py_files[@]}; do
if ! python common/fiximports.py "$filename"; then
echo "cannot fix imports of $filename"
RES=false
fi
done
$RES || warning "some import fixes failed -- not enforcing for now"

statis "running autopep8"
if [[ -z `which autopep8` ]]; then
warning "autopep8 is not installed"
else
for filename in ${py_files[@]}; do
if [[ -f common/pep8rc ]]; then
LINEWIDTH=$(grep -E "max-line-length" common/pep8rc | sed 's/ //g' | cut -d'=' -f 2)
# even if we dont enforce errors, if they can be fixed automatically, thats better..
IGNORES=E501,W6
# ignore is not None for SQLAlchemy code..
if [[ "$filename" =~ "/db/" ]]; then
IGNORES=$IGNORES,E711,E712
fi
autopep8 --in-place --max-line-length=$LINEWIDTH --ignore=$IGNORES "$filename"
else
warning "common/pep8rc not found"
fi
done
fi

[[ `git diff --name-only HEAD | wc -l` -gt 0 ]] && not_ok "style fixes to be committed"

Expand Down

0 comments on commit 2b27472

Please sign in to comment.