mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +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 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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user