mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00: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: 6c601e68a27e1c60b04c2a61830d1812cc883e09) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
f6609eebca
commit
f3b0d3eeae
@@ -944,6 +944,17 @@ def which(path, item, direction = 0, history = False, executable=False):
|
|||||||
return "", hist
|
return "", hist
|
||||||
return ""
|
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):
|
def to_boolean(string, default=None):
|
||||||
if not string:
|
if not string:
|
||||||
return default
|
return default
|
||||||
|
|||||||
Reference in New Issue
Block a user