def file(self, mode: str = 'w+b', buffering: int = -1, encoding: typing.Optional[str] = None,
newline: typing.Optional[str] = None, suffix: typing.Optional[str] = DEFAULT_SUFFIX,
prefix: typing.Optional[str] = DEFAULT_PREFIX, dir: typing.Optional[str] = None) -> typing.IO:
"""
Create a new temporary file within the scratch dir.
This returns the result of :func:`~tempfile.TemporaryFile` which returns a nameless, file-like object that
will cease to exist once it is closed.
:param mode: (Optional) mode to open the file with
:type mode: :class:`~str`
:param buffering: (Optional) size of the file buffer
:type buffering: :class:`~int`
:param encoding: (Optional) encoding to open the file with
:type encoding: :class:`~str` or :class:`~NoneType`
:param newline: (Optional) newline argument to open the file with
:type newline: :class:`~str` or :class:`~NoneType`
:param suffix: (Optional) filename suffix
:type suffix: :class:`~str` or :class:`~NoneType`
:param prefix: (Optional) filename prefix
:type prefix: :class:`~str` or :class:`~NoneType`
:param dir: (Optional) relative path to directory within the scratch dir where the file should exist
:type dir: :class:`~str` or :class:`~NoneType`
:return: file-like object as returned by :func:`~tempfile.TemporaryFile`
:rtype: :class:`~_io.BufferedRandom`
"""
return tempfile.TemporaryFile(mode, buffering, encoding, newline,
suffix, prefix, self.join(dir))
评论列表
文章目录