mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 21:09:03 +02:00
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>
This commit is contained in:
parent
f48d111e42
commit
dbe49d0ad1
|
@ -26,6 +26,8 @@ import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import importlib
|
||||||
|
from importlib import machinery
|
||||||
|
|
||||||
def logger_create(name, stream=None):
|
def logger_create(name, stream=None):
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
|
@ -50,12 +52,9 @@ def load_plugins(logger, plugins, pluginpath):
|
||||||
|
|
||||||
def load_plugin(name):
|
def load_plugin(name):
|
||||||
logger.debug('Loading plugin %s' % name)
|
logger.debug('Loading plugin %s' % name)
|
||||||
fp, pathname, description = imp.find_module(name, [pluginpath])
|
spec = importlib.machinery.PathFinder.find_spec(name, path=[pluginpath] )
|
||||||
try:
|
if spec:
|
||||||
return imp.load_module(name, fp, pathname, description)
|
return spec.loader.load_module()
|
||||||
finally:
|
|
||||||
if fp:
|
|
||||||
fp.close()
|
|
||||||
|
|
||||||
def plugin_name(filename):
|
def plugin_name(filename):
|
||||||
return os.path.splitext(os.path.basename(filename))[0]
|
return os.path.splitext(os.path.basename(filename))[0]
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import ast
|
import ast
|
||||||
import imp
|
import importlib
|
||||||
|
from importlib import machinery
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
@ -17,10 +18,7 @@ import sys
|
||||||
|
|
||||||
logger = logging.getLogger('pythondeps')
|
logger = logging.getLogger('pythondeps')
|
||||||
|
|
||||||
suffixes = []
|
suffixes = importlib.machinery.all_suffixes()
|
||||||
for triple in imp.get_suffixes():
|
|
||||||
suffixes.append(triple[0])
|
|
||||||
|
|
||||||
|
|
||||||
class PythonDepError(Exception):
|
class PythonDepError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue
Block a user