[oe-commits] Chris Larson : base: use a variable for the modules to import/inject

git version control git at git.openembedded.org
Mon Aug 23 21:28:36 UTC 2010


Module: openembedded.git
Branch: org.openembedded.dev
Commit: 5678affd4e1b6453d6802b8cfb7823fec6f47269
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=5678affd4e1b6453d6802b8cfb7823fec6f47269

Author: Chris Larson <chris_larson at mentor.com>
Date:   Mon Aug 23 16:39:20 2010 -0400

base: use a variable for the modules to import/inject

Signed-off-by: Chris Larson <chris_larson at mentor.com>

---

 classes/base.bbclass |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/classes/base.bbclass b/classes/base.bbclass
index 89f983f..ef9921d 100644
--- a/classes/base.bbclass
+++ b/classes/base.bbclass
@@ -9,31 +9,26 @@ inherit utils
 inherit utility-tasks
 inherit metadata_scm
 
-python sys_path_eh () {
-    if isinstance(e, bb.event.ConfigParsed):
-        import sys
-        import os
-        import time
+OE_IMPORTS += "oe.path oe.utils sys os time"
 
+python oe_import () {
+    if isinstance(e, bb.event.ConfigParsed):
         bbpath = e.data.getVar("BBPATH", True).split(":")
         sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath]
 
         def inject(name, value):
-            """Make a python object accessible from everywhere for the metadata"""
+            """Make a python object accessible from the metadata"""
             if hasattr(bb.utils, "_context"):
                 bb.utils._context[name] = value
             else:
                 __builtins__[name] = value
 
-        import oe.path
-        import oe.utils
-        inject("bb", bb)
-        inject("sys", sys)
-        inject("time", time)
-        inject("oe", oe)
+        for toimport in e.data.getVar("OE_IMPORTS", True).split():
+            imported = __import__(toimport)
+            inject(toimport, imported)
 }
 
-addhandler sys_path_eh
+addhandler oe_import
 
 die() {
 	oefatal "$*"





More information about the Openembedded-commits mailing list