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
1+ #! /usr/bin/env bash
2+ #
3+ # Run Python code tools (isort, black, flake8)
4+ #
25# ### SETUP ####################################################################
6+
7+ set -o errexit
38set -o errtrace
49set -o nounset
510
6- printf " \e[1m\e[7m %-80s\e[0m\n" ' isort'
11+ # shellcheck disable=SC2154
12+ trap ' _es=${?};
13+ printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
14+ printf " exited with a status of ${_es}\n";
15+ exit ${_es}' ERR
16+
17+ DIR_REPO=" $( cd -P -- " ${0%/* } /.." && pwd -P) "
18+ # https://en.wikipedia.org/wiki/ANSI_escape_code
19+ E0=" $( printf " \e[0m" ) " # reset
20+ E30=" $( printf " \e[30m" ) " # black foreground
21+ E31=" $( printf " \e[31m" ) " # red foreground
22+ E107=" $( printf " \e[107m" ) " # bright white background
23+
24+ # ### FUNCTIONS ################################################################
25+
26+ error_exit () {
27+ # Echo error message and exit with error
28+ echo -e " ${E31} ERROR:${E0} ${* } " 1>&2
29+ exit 1
30+ }
31+
32+ print_header () {
33+ # Print 80 character wide black on white heading with time
34+ printf " ${E30}${E107} # %-69s$( date ' +%T' ) ${E0} \n" " ${@ } "
35+ }
36+
37+ # ### MAIN #####################################################################
38+
39+ cd " ${DIR_REPO} "
40+
41+ print_header ' isort'
42+ # shellcheck disable=SC2068
743pipenv run isort ${@:- .}
844echo
945
10- printf " \e[1m\e[7m %-80s\e[0m\n" ' black'
46+ print_header ' black'
47+ # shellcheck disable=SC2068
1148pipenv run black ${@:- .}
1249echo
1350
14- printf " \e[1m\e[7m %-80s\e[0m\n" ' flake8'
51+ print_header ' flake8'
52+ # shellcheck disable=SC2068
1553pipenv run flake8 ${@:- .}
1654echo
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ def setup():
5050 args .dryrun = ""
5151 if not args .repos :
5252 raise ap .error ("at least one (1) REPOSITORY must be specified" )
53+ for i , repo in enumerate (args .repos ):
54+ args .repos [i ] = repo .strip ()
5355 return args
5456
5557
You can’t perform that action at this time.
0 commit comments