[gnome-continuous-yocto/gnomeostree-3.28-rocko: 2131/8267] bitbake: tinfoil: add context manager functions



commit 8f277fcf338cbbb191e4f1ccd547c52ef5f8a107
Author: Paul Eggleton <paul eggleton linux intel com>
Date:   Wed Aug 5 15:12:14 2015 +0100

    bitbake: 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)
            ...
    
    (Bitbake rev: f59bc6be2b4af1acdcf6a1b184956b5ffd297743)
    
    Signed-off-by: Paul Eggleton <paul eggleton linux intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 bitbake/lib/bb/tinfoil.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 95608ae..441be2c 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/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)


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