1. shirkey
  2. virtualenvwrapper.bitbucket

Commits

"Ste...@gmail.com>"  committed 42c3bc7

Moved shared functions into common.py, fixed bitbucket_hg.py, updated tests

  • Participants
  • Parent commits bc6c7b5
  • Branches default

Comments (0)

Files changed (6)

File .hgignore

View file
 virtualenvwrapper/docs
 .tox
 .idea
+*.*~
 
 syntax: re
 .DS_Store

File tests/test.sh

View file
 
 test_get_user_private_var () {
     export VIRTUALENVWRAPPER_BITBUCKET_USER=myuser
-    url=$("$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.bitbucket import get_url; print get_url("project")')
+    url=$("$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.common import get_url; print get_url("project")')
     assertSame 'ssh://hg@bitbucket.org/myuser/project' "$url"
     unset VIRTUALENVWRAPPER_BITBUCKET_USER
 }
 
 test_get_user_var () {
     unset VIRTUALENVWRAPPER_BITBUCKET_USER
-    url="$("$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.bitbucket import get_url; print get_url("project")')"
+    url="$("$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.common import get_url; print get_url("project")')"
     assertSame "ssh://hg@bitbucket.org/$USER/project" "$url"
 }
 

File virtualenvwrapper/__init__.py

View file
 """
 
 __import__('pkg_resources').declare_namespace(__name__)
-
-import logging
-import os
-import subprocess
-
-log = logging.getLogger(__name__)
-
-REPOSITORY_URL = 'ssh://{vc_type}@bitbucket.org/{user}/{project}'
-
-def get_url(project, vc_type='hg'):
-    """Return the URL for the given project.
-    """
-    # potential env vars for userid, in order of increased precedence
-    env_var_strings = ['USER','VIRTUALENVWRAPPER_BITBUCKET_USER'] 
-    env_vars = [(os.environ.get(env),env) for env in env_var_strings 
-                            if os.environ.get(env)]
-    if len(env_vars)<1:
-        log.error('Set one of the following: %s' % env_var_strings)
-        return None
-
-    user, source = env_vars[-1]
-    log.info('Pulling from Bitbucket as %s(=env var %s) using %s' % (user,source, vc_type))
-    url = REPOSITORY_URL.format(vc_type = vc_type, user=user, project=project)
-    return url
-
-def _template(args, vc_type):
-    """Clones a BitBucket.org repository into the project directory.
-    """
-    project = args[0]
-    url = get_url(project, vc_type)
-    if url:
-        log.info('Cloning %s', url)
-        subprocess.call([vc_type, 'clone', url, project], shell=False)
-    return

File virtualenvwrapper/bitbucket.py

View file
 # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
 #
 # retained default template of bitbucket for compatibility
-from virtualenvwrapper import _template
+from virtualenvwrapper.common import _template
 
 def template(args):
     return _template(args, 'hg')

File virtualenvwrapper/bitbucket_git.py

View file
 #
 # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
 #
-from virtualenvwrapper import _template
+from virtualenvwrapper.common import _template
 
 def template(args):
     return _template(args, 'git')

File virtualenvwrapper/bitbucket_hg.py

View file
 #
 # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
 #
-"""virtualenvwrapper.project plugin for bitbucket repositories
-"""
-import pkg_resources
-
-from virtualenvwrapper import log, _template
-
-VERSION_CONTROL_TYPE='hg'
+from virtualenvwrapper.common import _template
 
 def template(args):
-    log.info('Pulling from BitBucket using ' % VERSION_CONTROL_TYPE)
-    return _template(args, VERSION_CONTROL_TYPE)
+    return _template(args, 'hg')