From 0b38d75a44f409a9fa6719f2b6c402345d8de66d Mon Sep 17 00:00:00 2001 From: Aaron Rosen <aaronorosen@gmail.com> Date: Wed, 3 Sep 2014 22:16:48 -0700 Subject: [PATCH] Leverage openstack.common.importutils import_class This patch drops the import_class method from utils and instead leverages the one in openstack.common.importutils. Change-Id: I9f740b9941d477776597c4c4ab88a65a39fb4fb8 Closes-bug: 1365273 --- cinderclient/client.py | 3 +-- cinderclient/utils.py | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index 9e93b6775..75cd210b6 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -30,7 +30,6 @@ import requests from cinderclient import exceptions from cinderclient.openstack.common import importutils from cinderclient.openstack.common import strutils -from cinderclient import utils osprofiler_web = importutils.try_import("osprofiler.web") @@ -526,7 +525,7 @@ def get_client_class(version): (version, ', '.join(version_map))) raise exceptions.UnsupportedVersion(msg) - return utils.import_class(client_path) + return importutils.import_class(client_path) def Client(version, *args, **kwargs): diff --git a/cinderclient/utils.py b/cinderclient/utils.py index 876ed77d2..fcf9f689f 100644 --- a/cinderclient/utils.py +++ b/cinderclient/utils.py @@ -249,13 +249,6 @@ def safe_issubclass(*args): return False -def import_class(import_str): - """Returns a class from a string including module and class.""" - mod_str, _sep, class_str = import_str.rpartition('.') - __import__(mod_str) - return getattr(sys.modules[mod_str], class_str) - - def _load_entry_point(ep_name, name=None): """Try to load the entry point ep_name that matches name.""" for ep in pkg_resources.iter_entry_points(ep_name, name=name):