]> code.ossystems Code Review - openembedded-core.git/commitdiff
Switch from our own 'dummywrite' class to StringIO
authorChris Larson <chris_larson@mentor.com>
Wed, 16 Jun 2010 13:53:24 +0000 (06:53 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 2 Jul 2010 14:41:36 +0000 (15:41 +0100)
(Bitbake rev: f5b7e16adf86950d91a88a343031e71beb0f08a6)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/cooker.py

index 8f79c4f72c18cb8a6949592d95173e8c6f745fbc..fd59f052321138cdd57d62cce6f0570fd3b25d2d 100644 (file)
 
 from __future__ import print_function
 import sys, os, glob, os.path, re, time
+import sre_constants
+from cStringIO import StringIO
+from contextlib import closing
 import bb
 from bb import utils, data, parse, event, cache, providers, taskdata, command, runqueue
-import sre_constants
 
 class MultipleMatches(Exception):
     """
@@ -267,20 +269,15 @@ class BBCooker:
                 bb.msg.error(bb.msg.domain.Parsing, "%s" % e)
                 raise
 
-        class dummywrite:
-            def __init__(self):
-                self.writebuf = ""
-            def write(self, output):
-                self.writebuf = self.writebuf + output
-
         # emit variables and shell functions
         try:
             data.update_data(envdata)
-            wb = dummywrite()
-            data.emit_env(wb, envdata, True)
-            bb.msg.plain(wb.writebuf)
+            with closing(StringIO()) as env:
+                data.emit_env(env, envdata, True)
+                bb.msg.plain(env.getvalue())
         except Exception, e:
             bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
+
         # emit the metadata which isnt valid shell
         data.expandKeys(envdata)
         for e in envdata.keys():