mirror of
https://git.yoctoproject.org/poky
synced 2026-02-20 08:29:42 +01:00
bitbake: utils: add umask changing context manager
Add a umask context manager which can be used to temporarily change the umask in a 'with' block. (Bitbake rev: 6ca998054e422da72c7906d3ec4f204d88c32ee0) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
committed by
Steve Sakoman
parent
0b105ed7c8
commit
658a3832de
@@ -969,6 +969,17 @@ def which(path, item, direction = 0, history = False, executable=False):
|
||||
return "", hist
|
||||
return ""
|
||||
|
||||
@contextmanager
|
||||
def umask(new_mask):
|
||||
"""
|
||||
Context manager to set the umask to a specific mask, and restore it afterwards.
|
||||
"""
|
||||
current_mask = os.umask(new_mask)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
os.umask(current_mask)
|
||||
|
||||
def to_boolean(string, default=None):
|
||||
if not string:
|
||||
return default
|
||||
|
||||
Reference in New Issue
Block a user