]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bb.utils: use imp.get_suffixes for load_plugins
authorChristopher Larson <chris_larson@mentor.com>
Sat, 30 Apr 2016 19:40:58 +0000 (12:40 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 6 May 2016 09:19:59 +0000 (10:19 +0100)
Rather than hardcoding .py, use python's knowledge of its file extensions.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/utils.py

index 92f1b60206c9bc85d673cffead51d80a5b4e22f2..c54ff5b92b9bd306ec0c1e645ea6753f0a8c9495 100644 (file)
@@ -28,6 +28,7 @@ import bb.msg
 import multiprocessing
 import fcntl
 import imp
+import itertools
 import subprocess
 import glob
 import fnmatch
@@ -41,6 +42,8 @@ from ctypes import cdll
 
 
 logger = logging.getLogger("BitBake.Util")
+python_extensions = [e for e, _, _ in imp.get_suffixes()]
+
 
 def clean_context():
     return {
@@ -1465,8 +1468,12 @@ def load_plugins(logger, plugins, pluginpath):
                 fp.close()
 
     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__':
             plugin = load_plugin(name)
             if hasattr(plugin, 'plugin_init'):