mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 00:49:33 +02:00
bitbake: bb.utils: use imp.get_suffixes for load_plugins
Rather than hardcoding .py, use python's knowledge of its file extensions. (Bitbake rev: 09f838dbaefdaedc01a1f4818ed38280b38db744) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
7dc12110d4
commit
19e6fd5b7b
@@ -28,6 +28,7 @@ import bb.msg
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import fcntl
|
import fcntl
|
||||||
import imp
|
import imp
|
||||||
|
import itertools
|
||||||
import subprocess
|
import subprocess
|
||||||
import glob
|
import glob
|
||||||
import fnmatch
|
import fnmatch
|
||||||
@@ -41,6 +42,8 @@ from ctypes import cdll
|
|||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("BitBake.Util")
|
logger = logging.getLogger("BitBake.Util")
|
||||||
|
python_extensions = [e for e, _, _ in imp.get_suffixes()]
|
||||||
|
|
||||||
|
|
||||||
def clean_context():
|
def clean_context():
|
||||||
return {
|
return {
|
||||||
@@ -1465,8 +1468,12 @@ def load_plugins(logger, plugins, pluginpath):
|
|||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
logger.debug('Loading plugins from %s...' % pluginpath)
|
logger.debug('Loading plugins from %s...' % pluginpath)
|
||||||
for fn in glob.glob(os.path.join(pluginpath, '*.py')):
|
|
||||||
name = os.path.splitext(os.path.basename(fn))[0]
|
expanded = (glob.glob(os.path.join(pluginpath, '*' + ext))
|
||||||
|
for ext in python_extensions)
|
||||||
|
files = itertools.chain.from_iterable(expanded)
|
||||||
|
names = set(os.path.splitext(os.path.basename(fn))[0] for fn in files)
|
||||||
|
for name in names:
|
||||||
if name != '__init__':
|
if name != '__init__':
|
||||||
plugin = load_plugin(name)
|
plugin = load_plugin(name)
|
||||||
if hasattr(plugin, 'plugin_init'):
|
if hasattr(plugin, 'plugin_init'):
|
||||||
|
|||||||
Reference in New Issue
Block a user