commit d156cc8e670af5f6ba0d2e3512a444c00c59cc37 Author: Adin Scannell Date: Fri Sep 28 17:40:05 2012 -0400 Use a sensible name for extensions discovered on the python path. Using novaclient with some extensions via python code, you might have an invocation like this: extensions = shell.OpenStackComputeShell()._discover_extensions("1.1") novaclient = Client("1.1", user, apikey, project, authurl, extensions=extensions, endpoint_type=shell.DEFAULT_NOVA_ENDPOINT_TYPE, service_type=shell.DEFAULT_NOVA_SERVICE_TYPE) If you have an extension like 'myextension.py' in the v1_1/contrib directory, you'll end up with a very sensible attribute on the resulting novaclient object, i.e. novaclient.myextension If you have a package distributed in the package myextension_python_novaclient_ext, then it'll automatically be picked up as an extension (awesome!) but the name is not as intuitive. novaclient.myextension_python_novaclient_ext This patch simply changes this to use the Extension 'name' of myextension, even when matching extensions found in packages. The possibility of collisions exists, but is not really any more significant than before (where you might have different versions of the same package installed in the system or heck, even a bizarrely named 'myextension_python_novaclient_ext.py' in the contrib/ directory). Signed-off-by: Adin Scannell diff --git a/novaclient/shell.py b/novaclient/shell.py index 6bfba60..06ec9a5 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -266,12 +266,13 @@ class OpenStackComputeShell(object): def _discover_via_python_path(self): for (module_loader, name, _ispkg) in pkgutil.iter_modules(): - if name.endswith('python_novaclient_ext'): + if name.endswith('_python_novaclient_ext'): if not hasattr(module_loader, 'load_module'): # Python 2.6 compat: actually get an ImpImporter obj module_loader = module_loader.find_module(name) module = module_loader.load_module(name) + name = name[:-len('_python_novaclient_ext')] yield name, module def _discover_via_contrib_path(self, version):