Skip to content

Commit 0c282db

Browse files
committed
fix whitespace and rename a few worker functions to be consistent with the rest
1 parent b482f13 commit 0c282db

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

tests/test_tempfile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ test_bad_mktemp() {
4343
for mktemp_func in mktemp_nonzero mktemp_empty_string \
4444
mktemp_missing_executable mktemp_missing_result
4545
do
46-
__virtualenvwrapper_mktemp() { $mktemp_func "$@"; }
46+
virtualenvwrapper_mktemp() { $mktemp_func "$@"; }
4747
filename=$(virtualenvwrapper_tempfile hook 2>/dev/null)
4848
assertSame "($mktemp_func) Unexpected exit code $?" "1" "$?"
4949
done
5050

5151
# Restore the "real" definition of the replaceable function
52-
__virtualenvwrapper_mktemp() { command mktemp "$@"; }
52+
virtualenvwrapper_mktemp() { command mktemp "$@"; }
5353
}
5454

5555
test_no_such_tmpdir () {

virtualenvwrapper.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,25 @@ fi
8989
# existing builtin commands. We need to use a builtin for cd because
9090
# we are trying to change the state of the current shell, so we use
9191
# "builtin" for bash and zsh but "command" under ksh.
92-
function __virtualenvwrapper_cd {
93-
if [ -n "$BASH" ]
94-
then
95-
builtin \cd "$@"
96-
elif [ -n "$ZSH_VERSION" ]
97-
then
98-
builtin \cd "$@"
99-
else
100-
command \cd "$@"
101-
fi
92+
function virtualenvwrapper_cd {
93+
if [ -n "$BASH" ]
94+
then
95+
builtin \cd "$@"
96+
elif [ -n "$ZSH_VERSION" ]
97+
then
98+
builtin \cd "$@"
99+
else
100+
command \cd "$@"
101+
fi
102102
}
103103

104104
function virtualenvwrapper_expandpath {
105-
if [ "$1" = "" ]; then
106-
return 1
107-
else
108-
"$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')"
109-
return 0
110-
fi
105+
if [ "$1" = "" ]; then
106+
return 1
107+
else
108+
"$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')"
109+
return 0
110+
fi
111111
}
112112

113113
function virtualenvwrapper_derive_workon_home {
@@ -166,8 +166,8 @@ function virtualenvwrapper_verify_workon_home {
166166

167167
# Function to wrap mktemp so tests can replace it for error condition
168168
# testing.
169-
function __virtualenvwrapper_mktemp {
170-
command \mktemp "$@"
169+
function virtualenvwrapper_mktemp {
170+
command \mktemp "$@"
171171
}
172172

173173
# Expects 1 argument, the suffix for the new file.
@@ -176,7 +176,7 @@ function virtualenvwrapper_tempfile {
176176
typeset suffix=${1:-hook}
177177
typeset file
178178

179-
file="$(__virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)"
179+
file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)"
180180
if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ]
181181
then
182182
echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2
@@ -212,8 +212,8 @@ function virtualenvwrapper_run_hook {
212212
fi
213213
# cat "$hook_script"
214214
source "$hook_script"
215-
elif [ "${1}" = "initialize" ]
216-
then
215+
elif [ "${1}" = "initialize" ]
216+
then
217217
cat - 1>&2 <<EOF
218218
virtualenvwrapper.sh: There was a problem running the initialization hooks.
219219
@@ -424,7 +424,7 @@ function mkvirtualenv {
424424
virtualenvwrapper_verify_virtualenv || return 1
425425
(
426426
[ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT
427-
__virtualenvwrapper_cd "$WORKON_HOME" &&
427+
virtualenvwrapper_cd "$WORKON_HOME" &&
428428
"$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" &&
429429
[ -d "$WORKON_HOME/$envname" ] && \
430430
virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname"
@@ -485,7 +485,7 @@ function rmvirtualenv {
485485
# Move out of the current directory to one known to be
486486
# safe, in case we are inside the environment somewhere.
487487
typeset prior_dir="$(pwd)"
488-
__virtualenvwrapper_cd "$WORKON_HOME"
488+
virtualenvwrapper_cd "$WORKON_HOME"
489489

490490
virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name"
491491
command \rm -rf "$env_dir"
@@ -494,7 +494,7 @@ function rmvirtualenv {
494494
# If the directory we used to be in still exists, move back to it.
495495
if [ -d "$prior_dir" ]
496496
then
497-
__virtualenvwrapper_cd "$prior_dir"
497+
virtualenvwrapper_cd "$prior_dir"
498498
fi
499499
done
500500
}
@@ -505,7 +505,7 @@ function virtualenvwrapper_show_workon_options {
505505
# NOTE: DO NOT use ls here because colorized versions spew control characters
506506
# into the output list.
507507
# echo seems a little faster than find, even with -depth 3.
508-
(__virtualenvwrapper_cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$')
508+
(virtualenvwrapper_cd "$WORKON_HOME"; for f in */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate; do echo $f; done) 2>/dev/null | command \sed 's|^\./||' | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate||" | command \sort | (unset GREP_OPTIONS; command \egrep -v '^\*$')
509509
}
510510

511511
function _lsvirtualenv_usage {
@@ -752,14 +752,14 @@ function cdsitepackages {
752752
virtualenvwrapper_verify_workon_home || return 1
753753
virtualenvwrapper_verify_active_environment || return 1
754754
typeset site_packages="`virtualenvwrapper_get_site_packages_dir`"
755-
__virtualenvwrapper_cd "$site_packages"/$1
755+
virtualenvwrapper_cd "$site_packages"/$1
756756
}
757757

758758
# Does a ``cd`` to the root of the currently-active virtualenv.
759759
function cdvirtualenv {
760760
virtualenvwrapper_verify_workon_home || return 1
761761
virtualenvwrapper_verify_active_environment || return 1
762-
__virtualenvwrapper_cd $VIRTUAL_ENV/$1
762+
virtualenvwrapper_cd $VIRTUAL_ENV/$1
763763
}
764764

765765
# Shows the content of the site-packages directory of the currently-active
@@ -847,7 +847,7 @@ function cpvirtualenv {
847847
echo "Copying $src_name as $trg_name..."
848848
(
849849
[ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT
850-
__virtualenvwrapper_cd "$WORKON_HOME" &&
850+
virtualenvwrapper_cd "$WORKON_HOME" &&
851851
"$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg"
852852
[ -d "$trg" ] &&
853853
virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" &&

0 commit comments

Comments
 (0)