[oe-commits] [bitbake] 02/03: bb.utils: use imp.get_suffixes for load_plugins

git at git.openembedded.org git at git.openembedded.org
Fri May 6 09:20:36 UTC 2016


rpurdie pushed a commit to branch master
in repository bitbake.

commit 09f838dbaefdaedc01a1f4818ed38280b38db744
Author: Christopher Larson <chris_larson at mentor.com>
AuthorDate: Sat Apr 30 12:40:58 2016 -0700

    bb.utils: use imp.get_suffixes for load_plugins
    
    Rather than hardcoding .py, use python's knowledge of its file extensions.
    
    Signed-off-by: Christopher Larson <chris_larson at mentor.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/utils.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 92f1b60..c54ff5b 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -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'):

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list