diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-15 15:04:02 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-16 11:46:07 +0000 |
commit | dbe49d0ad197975e80c937e5e8da038d5c19e4c1 (patch) | |
tree | 4e4d8cccd82990f32c6fefa7f1a0672ec4653da8 /scripts | |
parent | f48d111e42398222e6ee8013a37ee35faf43ce09 (diff) | |
download | openembedded-core-contrib-dbe49d0ad197975e80c937e5e8da038d5c19e4c1.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: 24809582d4850190d87cd8eb8180d0dce215dbdf)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/scriptutils.py | 11 | ||||
-rwxr-xr-x | scripts/pythondeps | 8 |
2 files changed, 8 insertions, 11 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 import subprocess import sys import tempfile +import importlib +from importlib import machinery def logger_create(name, stream=None): logger = logging.getLogger(name) @@ -50,12 +52,9 @@ def load_plugins(logger, plugins, pluginpath): def load_plugin(name): logger.debug('Loading plugin %s' % name) - fp, pathname, description = imp.find_module(name, [pluginpath]) - try: - return imp.load_module(name, fp, pathname, description) - finally: - if fp: - fp.close() + spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] ) + if spec: + return spec.loader.load_module() def plugin_name(filename): return os.path.splitext(os.path.basename(filename))[0] diff --git a/scripts/pythondeps b/scripts/pythondeps index 590b9769e7..3e13a587ee 100755 --- a/scripts/pythondeps +++ b/scripts/pythondeps @@ -9,7 +9,8 @@ import argparse import ast -import imp +import importlib +from importlib import machinery import logging import os.path import sys @@ -17,10 +18,7 @@ import sys logger = logging.getLogger('pythondeps') -suffixes = [] -for triple in imp.get_suffixes(): - suffixes.append(triple[0]) - +suffixes = importlib.machinery.all_suffixes() class PythonDepError(Exception): pass |