diff options
author | Zuul <zuul@review.opendev.org> | 2020-09-09 18:07:18 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-09-09 18:07:18 +0000 |
commit | d0f10e3350a15916607ed0ff66be8ec033050d2b (patch) | |
tree | 60c03b9b8969bc553af48ce286776debfd78be30 /cinderclient | |
parent | 76f2b91d9add6113aa57829d8101647f0a5936d7 (diff) | |
parent | aebb6011e67955d5e54b8596eb0a3301877b9345 (diff) | |
download | python-cinderclient-d0f10e3350a15916607ed0ff66be8ec033050d2b.tar.gz |
Merge "Use importlib to take place of imp module"
Diffstat (limited to 'cinderclient')
-rw-r--r-- | cinderclient/client.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/cinderclient/client.py b/cinderclient/client.py index fdf1f36..63573a5 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -18,7 +18,7 @@ import glob import hashlib -import imp +import importlib.util import itertools import logging import os @@ -793,6 +793,15 @@ def _discover_via_python_path(): yield name, module +def load_module(name, path): + module_spec = importlib.util.spec_from_file_location( + name, path + ) + module = importlib.util.module_from_spec(module_spec) + module_spec.loader.exec_module(module) + return module + + def _discover_via_contrib_path(version): module_path = os.path.dirname(os.path.abspath(__file__)) version_str = "v%s" % version.replace('.', '_') @@ -805,7 +814,7 @@ def _discover_via_contrib_path(version): if name == "__init__": continue - module = imp.load_source(name, ext_path) + module = load_module(name, ext_path) yield name, module |