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 1919 - Fix a problem with ``virtualenvwrapper_show_workon_options `` that
2020 caused it to show ``* `` as the name of a virtualenv when no
2121 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.
2226
23272.0.2
2428
Original file line number Diff line number Diff line change 66"""Load hooks for virtualenvwrapper.
77"""
88
9+ import inspect
910import logging
1011import optparse
1112import os
@@ -24,6 +25,12 @@ def main():
2425 dest = 'sourcing' ,
2526 default = False ,
2627 )
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+ )
2734 parser .add_option ('-v' , '--verbose' ,
2835 help = 'Show more information on the console' ,
2936 action = 'store_const' ,
@@ -37,6 +44,12 @@ def main():
3744 const = 0 ,
3845 dest = 'verbose_level' ,
3946 )
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+ )
4053 parser .disable_interspersed_args () # stop when we hit an option without an '-'
4154 options , args = parser .parse_args ()
4255
@@ -66,7 +79,12 @@ def main():
6679 hook += '_source'
6780
6881 for ep in pkg_resources .iter_entry_points ('virtualenvwrapper.%s' % hook ):
82+ if options .names and ep .name not in options .names :
83+ continue
6984 plugin = ep .load ()
85+ if options .listing :
86+ print ' {0:10} -- {1}' .format (ep .name , inspect .getdoc (plugin ) or '' )
87+ continue
7088 if options .sourcing :
7189 # Show the shell commands so they can
7290 # be run in the calling shell.
You can’t perform that action at this time.
0 commit comments