diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-15 15:04:02 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-07-29 23:50:43 +0100 |
commit | a872c9619288744f55da64ebf599434053594238 (patch) | |
tree | 38de2004f3abde8e57fa7560ce24aa97aebfa082 /scripts/lib | |
parent | 4d63da3fad18264688debf0c3bce4b9d562c9d82 (diff) | |
download | poky-a872c9619288744f55da64ebf599434053594238.tar.gz |
scripts: Remove deprecated imp module usage
The imp module is deprecated, port the code over to use importlib
as recently done for bb.utils as well.
(From OE-Core rev: f3ba6cee5927c7475c3dc47658fa0548aec52115)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/scriptutils.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 31e48ea4dc..3c60c3a1e6 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py | |||
@@ -26,6 +26,8 @@ import string | |||
26 | import subprocess | 26 | import subprocess |
27 | import sys | 27 | import sys |
28 | import tempfile | 28 | import tempfile |
29 | import importlib | ||
30 | from importlib import machinery | ||
29 | 31 | ||
30 | def logger_create(name, stream=None): | 32 | def logger_create(name, stream=None): |
31 | logger = logging.getLogger(name) | 33 | logger = logging.getLogger(name) |
@@ -50,12 +52,9 @@ def load_plugins(logger, plugins, pluginpath): | |||
50 | 52 | ||
51 | def load_plugin(name): | 53 | def load_plugin(name): |
52 | logger.debug('Loading plugin %s' % name) | 54 | logger.debug('Loading plugin %s' % name) |
53 | fp, pathname, description = imp.find_module(name, [pluginpath]) | 55 | spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) |
54 | try: | 56 | if spec: |
55 | return imp.load_module(name, fp, pathname, description) | 57 | return spec.loader.load_module() |
56 | finally: | ||
57 | if fp: | ||
58 | fp.close() | ||
59 | 58 | ||
60 | def plugin_name(filename): | 59 | def plugin_name(filename): |
61 | return os.path.splitext(os.path.basename(filename))[0] | 60 | return os.path.splitext(os.path.basename(filename))[0] |