summaryrefslogtreecommitdiff
path: root/cinderclient
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-09-09 18:07:18 +0000
committerGerrit Code Review <review@openstack.org>2020-09-09 18:07:18 +0000
commitd0f10e3350a15916607ed0ff66be8ec033050d2b (patch)
tree60c03b9b8969bc553af48ce286776debfd78be30 /cinderclient
parent76f2b91d9add6113aa57829d8101647f0a5936d7 (diff)
parentaebb6011e67955d5e54b8596eb0a3301877b9345 (diff)
downloadpython-cinderclient-d0f10e3350a15916607ed0ff66be8ec033050d2b.tar.gz
Merge "Use importlib to take place of imp module"
Diffstat (limited to 'cinderclient')
-rw-r--r--cinderclient/client.py13
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