[gnome-continuous-yocto/gnomeostree-3.28-rocko: 61/8267] bitbake: bb.utils: add load_plugins from scriptutils



commit 7dc12110d400caaed8198ecdaeb86a65f2a3d984
Author: Christopher Larson <chris_larson mentor com>
Date:   Sat Apr 30 12:40:57 2016 -0700

    bitbake: bb.utils: add load_plugins from scriptutils
    
    Imported as of oe-core 184a256.
    
    (Bitbake rev: 99db61bf816d9c735032caa762aae8e6a0803402)
    
    Signed-off-by: Christopher Larson <chris_larson mentor com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/lib/bb/utils.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 3544bbe..92f1b60 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -27,6 +27,7 @@ import bb
 import bb.msg
 import multiprocessing
 import fcntl
+import imp
 import subprocess
 import glob
 import fnmatch
@@ -1451,3 +1452,23 @@ def export_proxies(d):
                 exported = True
 
     return exported
+
+
+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()
+
+    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]
+        if name != '__init__':
+            plugin = load_plugin(name)
+            if hasattr(plugin, 'plugin_init'):
+                plugin.plugin_init(plugins)
+            plugins.append(plugin)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]