File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 19
19
- Fix a problem with ``virtualenvwrapper_show_workon_options `` that
20
20
caused it to show ``* `` as the name of a virtualenv when no
21
21
environments had yet been created.
22
+ - Change the hook loader so it can be told to run only a set of
23
+ named hooks.
24
+ - Add support for listing the available hooks, to be used in help
25
+ output of commands like virtualenvwrapper.project's mkproject.
22
26
23
27
2.0.2
24
28
Original file line number Diff line number Diff line change 6
6
"""Load hooks for virtualenvwrapper.
7
7
"""
8
8
9
+ import inspect
9
10
import logging
10
11
import optparse
11
12
import os
@@ -24,6 +25,12 @@ def main():
24
25
dest = 'sourcing' ,
25
26
default = False ,
26
27
)
28
+ parser .add_option ('-l' , '--list' ,
29
+ help = 'Print a list of the plugins available for the given hook' ,
30
+ action = 'store_true' ,
31
+ default = False ,
32
+ dest = 'listing' ,
33
+ )
27
34
parser .add_option ('-v' , '--verbose' ,
28
35
help = 'Show more information on the console' ,
29
36
action = 'store_const' ,
@@ -37,6 +44,12 @@ def main():
37
44
const = 0 ,
38
45
dest = 'verbose_level' ,
39
46
)
47
+ parser .add_option ('-n' , '--name' ,
48
+ help = 'Only run the hook from the named plugin' ,
49
+ action = 'append' ,
50
+ dest = 'names' ,
51
+ default = [],
52
+ )
40
53
parser .disable_interspersed_args () # stop when we hit an option without an '-'
41
54
options , args = parser .parse_args ()
42
55
@@ -66,7 +79,12 @@ def main():
66
79
hook += '_source'
67
80
68
81
for ep in pkg_resources .iter_entry_points ('virtualenvwrapper.%s' % hook ):
82
+ if options .names and ep .name not in options .names :
83
+ continue
69
84
plugin = ep .load ()
85
+ if options .listing :
86
+ print ' {0:10} -- {1}' .format (ep .name , inspect .getdoc (plugin ) or '' )
87
+ continue
70
88
if options .sourcing :
71
89
# Show the shell commands so they can
72
90
# be run in the calling shell.
You can’t perform that action at this time.
0 commit comments