~ubuntu-branches/ubuntu/trusty/virtualenvwrapper/trusty-proposed

« back to all changes in this revision

Viewing changes to virtualenvwrapper/project.py

  • Committer: Package Import Robot
  • Author(s): Jan Dittberner
  • Date: 2012-01-08 18:27:55 UTC
  • mfrom: (1.2.14)
  • Revision ID: package-import@ubuntu.com-20120108182755-pan9qj3tb0u2o9bd
Tags: 2.11.1-1
* New upstream version.
* refresh debian/patches/debianspecific-setup.py.patch and
  debian/patches/remove_bitbucket_support.patch
* update debian/copyright format and copyright years

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# encoding: utf-8
 
3
#
 
4
# Copyright (c) 2010 Doug Hellmann.  All rights reserved.
 
5
#
 
6
"""virtualenvwrapper.project
 
7
"""
 
8
 
 
9
import logging
 
10
import os
 
11
 
 
12
import pkg_resources
 
13
 
 
14
from virtualenvwrapper.user_scripts import make_hook, run_global
 
15
 
 
16
log = logging.getLogger(__name__)
 
17
 
 
18
GLOBAL_HOOKS = [
 
19
    # mkproject
 
20
    ("premkproject",
 
21
     "This hook is run after a new project is created and before it is activated."),
 
22
    ("postmkproject",
 
23
     "This hook is run after a new project is activated."),
 
24
 
 
25
    # rmproject
 
26
    ("prermproject",
 
27
     "This hook is run before a project is deleted."),
 
28
    ("postrmproject",
 
29
     "This hook is run after a project is deleted."),
 
30
    ]
 
31
 
 
32
def initialize(args):
 
33
    """Set up user hooks
 
34
    """
 
35
    for filename, comment in GLOBAL_HOOKS:
 
36
        make_hook(os.path.join('$VIRTUALENVWRAPPER_HOOK_DIR', filename), comment)
 
37
    return
 
38
 
 
39
 
 
40
def pre_mkproject(args):
 
41
    log.debug('pre_mkproject %s', str(args))
 
42
    envname=args[0]
 
43
    run_global('premkproject', *args)
 
44
    return
 
45
 
 
46
def post_mkproject_source(args):
 
47
    return """
 
48
#
 
49
# Run user-provided scripts
 
50
#
 
51
[ -f "$WORKON_HOME/postmkproject" ] && source "$WORKON_HOME/postmkproject"
 
52
"""
 
53
 
 
54
def post_activate_source(args):
 
55
    return """
 
56
#
 
57
# Change to the project directory
 
58
#
 
59
[ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ] && cd "$(cat \"$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME\")"
 
60
"""