Skip to content

Commit c438540

Browse files
aaronorosenSteve Martinelli
authored andcommitted
Leverage openstack.common.importutils for import_class
This patch drops the import_utils method from common.utils and leverages it from openstack.common.importutils instead. Change-Id: If7e7383aa742afe44f750f916c0d90d747793150 Closes-bug: 1365273
1 parent b1663c9 commit c438540

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

openstackclient/common/utils.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import logging
2020
import os
2121
import six
22-
import sys
2322
import time
2423

2524
from openstackclient.common import exceptions
25+
from openstackclient.openstack.common import importutils
2626

2727

2828
def find_resource(manager, name_or_id):
@@ -157,17 +157,6 @@ def env(*vars, **kwargs):
157157
return kwargs.get('default', '')
158158

159159

160-
def import_class(import_str):
161-
"""Returns a class from a string including module and class
162-
163-
:param import_str: a string representation of the class name
164-
:rtype: the requested class
165-
"""
166-
mod_str, _sep, class_str = import_str.rpartition('.')
167-
__import__(mod_str)
168-
return getattr(sys.modules[mod_str], class_str)
169-
170-
171160
def get_client_class(api_name, version, version_map):
172161
"""Returns the client class for the requested API version
173162
@@ -183,7 +172,7 @@ def get_client_class(api_name, version, version_map):
183172
(api_name, version, ', '.join(version_map.keys())))
184173
raise exceptions.UnsupportedVersion(msg)
185174

186-
return import_class(client_path)
175+
return importutils.import_class(client_path)
187176

188177

189178
def wait_for_status(status_f,

0 commit comments

Comments
 (0)