Commits

barberj committed 3c47492

Updating namespace on helper functions and fixing expandpath tests and discovered bug concerning user being a var.

Comments (0)

Files changed (2)

tests/test_expandpath.sh

 }
 
 test_tilde() {
-    assertSame "$HOME" "$(expandpath ~)"
+    assertSame "$HOME" "$(virtualenvwrapper_expandpath ~)"
 }
 
 test_vars() {
-    assertSame "$HOME" "$(expandpath $HOME)"
+    assertSame "$HOME" "$(virtualenvwrapper_expandpath '$HOME')"
 }
 
 test_tilde_vars() {
-    assertSame "$HOME" "$(expandpath ~$USER)"
+    assertSame "$HOME" "$(virtualenvwrapper_expandpath '~$USER')"
 }
 
 . "$test_dir/shunit2"

virtualenvwrapper.sh

     export VIRTUALENVWRAPPER_PROJECT_FILENAME=".project"
 fi
 
-function expandpath {
+function virtualenvwrapper_expandpath {
         if [ "$1" = "" ]; then
             return 1
         else
-            "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.realpath(os.path.expandvars(os.path.expanduser(\"$1\")))+'\n')"
+            "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.realpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')"
             return 0
         fi
 }
         # - Removing extra slashes (e.g., when TMPDIR ends in a slash)
         # - Expanding variables (e.g., $foo)
         # - Converting ~s to complete paths (e.g., ~/ to /home/brian/ and ~arthur to /home/arthur)
-        workon_home_dir=$(expandpath $workon_home_dir)
+        workon_home_dir=$(virtualenvwrapper_expandpath $workon_home_dir)
     fi
 
     echo "$workon_home_dir"
             -r)
                 i=$(( $i + 1 ));
                 requirements="${in_args[$i]}";
-                requirements=$(expandpath $requirements);;
+                requirements=$(virtualenvwrapper_expandpath $requirements);;
             *)
                 if [ ${#out_args} -gt 0 ]
                 then
     fi
 }
 
-function copy_virtualenv_directory {
+function virtualenvwrapper_copy_virtualenv_directory {
     typeset source="$1"
     typeset target="$2"
 
         return 1
     fi
 
-    copy_virtualenv_directory "$source_env" "$target_env"
+    virtualenvwrapper_copy_virtualenv_directory "$source_env" "$target_env"
 
     (\cd "$WORKON_HOME" && (
         virtualenvwrapper_run_hook "pre_cpvirtualenv" "$env_name" "$new_env";
     virtualenvwrapper_verify_virtualenv || return 1
 
     # source path for the virtualenv to import
-    typeset srcvirtualenv=$(expandpath "$1")
+    typeset srcvirtualenv=$(virtualenvwrapper_expandpath "$1")
     # second parameter is optional,
     # its the target environment name
     # incase they want it different 
 
     echo "Importing $srcvirtualenv as $envname..."
 
-    copy_virtualenv_directory "$srcvirtualenv" "$targetenv"
+    virtualenvwrapper_copy_virtualenv_directory "$srcvirtualenv" "$targetenv"
 
     # need to add user scripts
     virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname"