[oe-commits] [bitbake] 01/18: tinfoil: add context manager functions

git at git.openembedded.org git at git.openembedded.org
Wed Aug 31 10:54:07 UTC 2016


rpurdie pushed a commit to branch master-next
in repository bitbake.

commit 16567ebbd1d9f86b9c799a209a6ec1d313f69fe3
Author: Paul Eggleton <paul.eggleton at linux.intel.com>
AuthorDate: Wed Aug 5 15:12:14 2015 +0100

    tinfoil: add context manager functions
    
    Since calling the shutdown() function is highly recommended, make
    tinfoil objects a little easier to deal with by adding context manager
    support - so you can do the following:
    
        with bb.tinfoil.Tinfoil() as tinfoil:
            tinfoil.prepare(True)
            ...
    
    Signed-off-by: Paul Eggleton <paul.eggleton at linux.intel.com>
---
 lib/bb/tinfoil.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 95608ae..441be2c 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -59,6 +59,12 @@ class Tinfoil:
     def register_idle_function(self, function, data):
         pass
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, type, value, traceback):
+        self.shutdown()
+
     def parseRecipes(self):
         sys.stderr.write("Parsing recipes..")
         self.logger.setLevel(logging.WARNING)

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


More information about the Openembedded-commits mailing list