diff options
author | Jürg Billeter <j@bitron.ch> | 2020-02-27 14:43:50 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2020-03-10 15:46:04 +0000 |
commit | e4d49bca961d94d2e5ce0fb3e42f66154e0a3a87 (patch) | |
tree | 1b30dfbe494e08f0f74831932aca0cf57ff699fb /src/buildstream/utils.py | |
parent | 7fbfccce44247122c5b9257e73328de16afa0445 (diff) | |
download | buildstream-e4d49bca961d94d2e5ce0fb3e42f66154e0a3a87.tar.gz |
utils.py: Add mode and encoding parameters to _tempnamedfile()
Diffstat (limited to 'src/buildstream/utils.py')
-rw-r--r-- | src/buildstream/utils.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index b588566df..997c073b9 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -1168,6 +1168,8 @@ def _tempdir(*, suffix="", prefix="tmp", dir): # pylint: disable=redefined-buil # which is guaranteed to be named and have an entry in the filesystem. # # Args: +# mode (str): The mode in which the file is opened +# encoding (str): The name of the encoding used to decode or encode the file # dir (str): A path to a parent directory for the temporary file # suffix (str): A suffix for the temproary file name # prefix (str): A prefix for the temporary file name @@ -1180,7 +1182,7 @@ def _tempdir(*, suffix="", prefix="tmp", dir): # pylint: disable=redefined-buil # on SIGTERM. # @contextmanager -def _tempnamedfile(suffix="", prefix="tmp", dir=None): # pylint: disable=redefined-builtin +def _tempnamedfile(mode="w+b", encoding=None, suffix="", prefix="tmp", dir=None): # pylint: disable=redefined-builtin temp = None def close_tempfile(): @@ -1188,7 +1190,7 @@ def _tempnamedfile(suffix="", prefix="tmp", dir=None): # pylint: disable=redefi temp.close() with _signals.terminator(close_tempfile), tempfile.NamedTemporaryFile( - suffix=suffix, prefix=prefix, dir=dir + mode=mode, encoding=encoding, suffix=suffix, prefix=prefix, dir=dir ) as temp: yield temp |