| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ This module creates temporary files and directories. It works on all | |||
| 18 | 18 | supported platforms. :class:`TemporaryFile`, :class:`NamedTemporaryFile`, | |
| 19 | 19 | :class:`TemporaryDirectory`, and :class:`SpooledTemporaryFile` are high-level | |
| 20 | 20 | interfaces which provide automatic cleanup and can be used as | |
| 21 | - context managers. :func:`mkstemp` and | ||
| 21 | + :term:`context managers <context manager>`. :func:`mkstemp` and | ||
| 22 | 22 | :func:`mkdtemp` are lower-level functions which require manual cleanup. | |
| 23 | 23 | ||
| 24 | 24 | All the user-callable functions and constructors take additional arguments which | |
@@ -41,7 +41,7 @@ The module defines the following user-callable items: | |||
| 41 | 41 | this; your code should not rely on a temporary file created using this | |
| 42 | 42 | function having or not having a visible name in the file system. | |
| 43 | 43 | ||
| 44 | - The resulting object can be used as a context manager (see | ||
| 44 | + The resulting object can be used as a :term:`context manager` (see | ||
| 45 | 45 | :ref:`tempfile-examples`). On completion of the context or | |
| 46 | 46 | destruction of the file object the temporary file will be removed | |
| 47 | 47 | from the filesystem. | |
@@ -87,9 +87,9 @@ The module defines the following user-callable items: | |||
| 87 | 87 | determine whether and how the named file should be automatically deleted. | |
| 88 | 88 | ||
| 89 | 89 | The returned object is always a :term:`file-like object` whose :attr:`!file` | |
| 90 | - attribute is the underlying true file object. This :term:`file-like object` | ||
| 90 | + attribute is the underlying true file object. This file-like object | ||
| 91 | 91 | can be used in a :keyword:`with` statement, just like a normal file. The | |
| 92 | - name of the temporary file can be retrieved from the :attr:`name` attribute | ||
| 92 | + name of the temporary file can be retrieved from the :attr:`!name` attribute | ||
| 93 | 93 | of the returned file-like object. On Unix, unlike with the | |
| 94 | 94 | :func:`TemporaryFile`, the directory entry does not get unlinked immediately | |
| 95 | 95 | after the file creation. | |
@@ -151,18 +151,20 @@ The module defines the following user-callable items: | |||
| 151 | 151 | contents are written to disk and operation proceeds as with | |
| 152 | 152 | :func:`TemporaryFile`. | |
| 153 | 153 | ||
| 154 | - The resulting file has one additional method, :func:`rollover`, which | ||
| 155 | - causes the file to roll over to an on-disk file regardless of its size. | ||
| 154 | + .. method:: SpooledTemporaryFile.rollover | ||
| 156 | 155 | ||
| 157 | - The returned object is a file-like object whose :attr:`_file` attribute | ||
| 156 | + The resulting file has one additional method, :meth:`!rollover`, which | ||
| 157 | + causes the file to roll over to an on-disk file regardless of its size. | ||
| 158 | + | ||
| 159 | + The returned object is a file-like object whose :attr:`!_file` attribute | ||
| 158 | 160 | is either an :class:`io.BytesIO` or :class:`io.TextIOWrapper` object | |
| 159 | 161 | (depending on whether binary or text *mode* was specified) or a true file | |
| 160 | - object, depending on whether :func:`rollover` has been called. This | ||
| 162 | + object, depending on whether :meth:`rollover` has been called. This | ||
| 161 | 163 | file-like object can be used in a :keyword:`with` statement, just like | |
| 162 | 164 | a normal file. | |
| 163 | 165 | ||
| 164 | 166 | .. versionchanged:: 3.3 | |
| 165 | - the truncate method now accepts a ``size`` argument. | ||
| 167 | + the truncate method now accepts a *size* argument. | ||
| 166 | 168 | ||
| 167 | 169 | .. versionchanged:: 3.8 | |
| 168 | 170 | Added *errors* parameter. | |
@@ -176,24 +178,28 @@ The module defines the following user-callable items: | |||
| 176 | 178 | .. class:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False, *, delete=True) | |
| 177 | 179 | ||
| 178 | 180 | This class securely creates a temporary directory using the same rules as :func:`mkdtemp`. | |
| 179 | - The resulting object can be used as a context manager (see | ||
| 181 | + The resulting object can be used as a :term:`context manager` (see | ||
| 180 | 182 | :ref:`tempfile-examples`). On completion of the context or destruction | |
| 181 | 183 | of the temporary directory object, the newly created temporary directory | |
| 182 | 184 | and all its contents are removed from the filesystem. | |
| 183 | 185 | ||
| 184 | - The directory name can be retrieved from the :attr:`name` attribute of the | ||
| 185 | - returned object. When the returned object is used as a context manager, the | ||
| 186 | - :attr:`name` will be assigned to the target of the :keyword:`!as` clause in | ||
| 187 | - the :keyword:`with` statement, if there is one. | ||
| 188 | - | ||
| 189 | - The directory can be explicitly cleaned up by calling the | ||
| 190 | - :func:`cleanup` method. If *ignore_cleanup_errors* is true, any unhandled | ||
| 191 | - exceptions during explicit or implicit cleanup (such as a | ||
| 192 | - :exc:`PermissionError` removing open files on Windows) will be ignored, | ||
| 193 | - and the remaining removable items deleted on a "best-effort" basis. | ||
| 194 | - Otherwise, errors will be raised in whatever context cleanup occurs | ||
| 195 | - (the :func:`cleanup` call, exiting the context manager, when the object | ||
| 196 | - is garbage-collected or during interpreter shutdown). | ||
| 186 | + .. attribute:: TemporaryDirectory.name | ||
| 187 | + | ||
| 188 | + The directory name can be retrieved from the :attr:`!name` attribute of the | ||
| 189 | + returned object. When the returned object is used as a :term:`context manager`, the | ||
| 190 | + :attr:`!name` will be assigned to the target of the :keyword:`!as` clause in | ||
| 191 | + the :keyword:`with` statement, if there is one. | ||
| 192 | + | ||
| 193 | + .. method:: TemporaryDirectory.cleanup | ||
| 194 | + | ||
| 195 | + The directory can be explicitly cleaned up by calling the | ||
| 196 | + :meth:`!cleanup` method. If *ignore_cleanup_errors* is true, any unhandled | ||
| 197 | + exceptions during explicit or implicit cleanup (such as a | ||
| 198 | + :exc:`PermissionError` removing open files on Windows) will be ignored, | ||
| 199 | + and the remaining removable items deleted on a "best-effort" basis. | ||
| 200 | + Otherwise, errors will be raised in whatever context cleanup occurs | ||
| 201 | + (the :meth:`!cleanup` call, exiting the context manager, when the object | ||
| 202 | + is garbage-collected or during interpreter shutdown). | ||
| 197 | 203 | ||
| 198 | 204 | The *delete* parameter can be used to disable cleanup of the directory tree | |
| 199 | 205 | upon exiting the context. While it may seem unusual for a context manager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,6 @@ Doc/library/sunau.rst | |||
| 107 | 107 | Doc/library/syslog.rst | |
| 108 | 108 | Doc/library/tarfile.rst | |
| 109 | 109 | Doc/library/telnetlib.rst | |
| 110 | - Doc/library/tempfile.rst | ||
| 111 | 110 | Doc/library/termios.rst | |
| 112 | 111 | Doc/library/test.rst | |
| 113 | 112 | Doc/library/tkinter.rst | |
| Back | FazBrowse Home | New Git URL |
0 commit comments