1#!/usr/local/bin/bash 2# 3# 4# 5 6function usage() { 7 echo 8 echo " Seahub project code checker." 9 echo 10 echo " It runs pylint on the code and prints the result." 11 echo 12 echo " To check a file:" 13 echo 14 echo " ./code-check.sh seahub.views.file" 15 echo 16 echo " To check a module:" 17 echo 18 echo " ./code-check.sh seahub.views" 19 echo 20} 21 22if [[ $# == 0 ]]; then 23 usage; 24 exit 1 25fi 26 27if [[ $# == 1 ]]; then 28 if [[ $1 == "-h" || $1 == "--help" ]]; then 29 usage; 30 exit 1 31 fi 32fi 33 34SCRIPT=$(readlink -f "$0") 35PROJECT_DIR=$(dirname "${SCRIPT}") 36 37cd ${PROJECT_DIR} 38 39if ! which pylint 2>/dev/null 1>&2; then 40 echo 41 echo "Pylint not found. Please install it first by:" 42 echo 43 echo " sudo pip install pylint" 44 echo 45 exit 1 46fi 47 48pylintrc=${PROJECT_DIR}/pylintrc 49if ! [[ -f ${pylintrc} ]]; then 50 echo "${pylintrc} not found" 51 echo 52 echo "mv pylintrc.template pylintrc" 53 echo 54 55 exit 1 56fi 57 58pylint --rcfile=${pylintrc} -E $@ 59