File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /bin/bash -e
1+ #! /bin/bash
22
33ROOT_DIR=" $( git rev-parse --show-toplevel) "
44source " ${ROOT_DIR} /scripts/helpers"
55
6+ header " Checking imports order with isort"
7+
68if [ -n " $( check_if_installed docker) " ]; then
7- docker run -v " ${PWD} :/code" sergioteula/pytools isort -c .
9+ docker run -v " ${PWD} :/code" sergioteula/pytools isort -c --color .
810elif [ -n " $( check_if_installed isort) " ]; then
9- isort -c .
11+ isort -c --color .
12+ else
13+ error " isort is not installed"
14+ exit 1
15+ fi
16+
17+ EXIT_CODE=" $? "
18+ if [ " $EXIT_CODE " = " 0" ]; then
19+ success " Imports are correctly ordered"
1020else
11- echo " Please install Docker or isort "
21+ error " Imports order is not correct "
1222 exit 1
1323fi
Original file line number Diff line number Diff line change 11#! /bin/bash -e
22
3+ BLUE=" \033[0;34m"
4+ GREEN=" \033[0;32m"
5+ RED=" \033[0;31m"
6+ YELLOW=" \033[0;33m"
7+ NC=" \033[0m"
8+ LINE=" --------------------------------------------------------------------"
9+
310check_if_installed () {
411 if [ -x " $( command -v " ${1} " ) " ]; then
512 echo " ${1} is installed"
613 fi
714}
15+
16+ header (){
17+ echo -e " \n${BLUE}${* } \n${LINE}${NC} "
18+ }
19+
20+ subheader (){
21+ echo -e " \n${BLUE} # ${* }${NC} "
22+ }
23+
24+ warning (){
25+ echo -e " ${YELLOW} WARNING: ${* }${NC} \n"
26+ }
27+
28+ error (){
29+ echo -e " ${RED} ERROR: ${* }${NC} \n"
30+ }
31+
32+ success (){
33+ echo -e " ${GREEN}${* }${NC} \n"
34+ }
You can’t perform that action at this time.
0 commit comments