@@ -109,7 +109,7 @@ Some facts and figures:
109
109
``'filemode|[compression]' ``. :func: `tarfile.open ` will return a :class: `TarFile `
110
110
object that processes its data as a stream of blocks. No random seeking will
111
111
be done on the file. If given, *fileobj * may be any object that has a
112
- :meth: `read ` or :meth: `write ` method (depending on the *mode *). *bufsize *
112
+ :meth: `~io.TextIOBase. read ` or :meth: `~io.TextIOBase. write ` method (depending on the *mode *). *bufsize *
113
113
specifies the blocksize and defaults to ``20 * 512 `` bytes. Use this variant
114
114
in combination with e.g. ``sys.stdin ``, a socket :term: `file object ` or a tape
115
115
device. However, such a :class: `TarFile ` object is limited in that it does
@@ -245,6 +245,51 @@ The following constants are available at the module level:
245
245
The default character encoding: ``'utf-8' `` on Windows, the value returned by
246
246
:func: `sys.getfilesystemencoding ` otherwise.
247
247
248
+ .. data :: REGTYPE
249
+ AREGTYPE
250
+
251
+ A regular file :attr: `~TarInfo.type `.
252
+
253
+ .. data :: LNKTYPE
254
+
255
+ A link (inside tarfile) :attr: `~TarInfo.type `.
256
+
257
+ .. data :: SYMTYPE
258
+
259
+ A symbolic link :attr: `~TarInfo.type `.
260
+
261
+ .. data :: CHRTYPE
262
+
263
+ A character special device :attr: `~TarInfo.type `.
264
+
265
+ .. data :: BLKTYPE
266
+
267
+ A block special device :attr: `~TarInfo.type `.
268
+
269
+ .. data :: DIRTYPE
270
+
271
+ A directory :attr: `~TarInfo.type `.
272
+
273
+ .. data :: FIFOTYPE
274
+
275
+ A FIFO special device :attr: `~TarInfo.type `.
276
+
277
+ .. data :: CONTTYPE
278
+
279
+ A contiguous file :attr: `~TarInfo.type `.
280
+
281
+ .. data :: GNUTYPE_LONGNAME
282
+
283
+ A GNU tar longname :attr: `~TarInfo.type `.
284
+
285
+ .. data :: GNUTYPE_LONGLINK
286
+
287
+ A GNU tar longlink :attr: `~TarInfo.type `.
288
+
289
+ .. data :: GNUTYPE_SPARSE
290
+
291
+ A GNU tar sparse file :attr: `~TarInfo.type `.
292
+
248
293
249
294
Each of the following constants defines a tar archive format that the
250
295
:mod: `tarfile ` module is able to create. See section :ref: `tar-formats ` for
@@ -315,7 +360,7 @@ be finalized; only the internally used file object will be closed. See the
315
360
316
361
*name * is the pathname of the archive. *name * may be a :term: `path-like object `.
317
362
It can be omitted if *fileobj * is given.
318
- In this case, the file object's :attr: `name ` attribute is used if it exists.
363
+ In this case, the file object's :attr: `! name ` attribute is used if it exists.
319
364
320
365
*mode * is either ``'r' `` to read from an existing archive, ``'a' `` to append
321
366
data to an existing file, ``'w' `` to create a new file overwriting an existing
@@ -349,7 +394,7 @@ be finalized; only the internally used file object will be closed. See the
349
394
messages). The messages are written to ``sys.stderr ``.
350
395
351
396
*errorlevel * controls how extraction errors are handled,
352
- see :attr: `the corresponding attribute <~ TarFile.errorlevel> `.
397
+ see :attr: `the corresponding attribute <TarFile.errorlevel> `.
353
398
354
399
The *encoding * and *errors * arguments define the character encoding to be
355
400
used for reading or writing the archive and how conversion errors are going
@@ -632,8 +677,8 @@ It does *not* contain the file's data itself.
632
677
:meth: `~TarFile.getmember `, :meth: `~TarFile.getmembers ` and
633
678
:meth: `~TarFile.gettarinfo `.
634
679
635
- Modifying the objects returned by :meth: `~! TarFile.getmember ` or
636
- :meth: `~! TarFile.getmembers ` will affect all subsequent
680
+ Modifying the objects returned by :meth: `~TarFile.getmember ` or
681
+ :meth: `~TarFile.getmembers ` will affect all subsequent
637
682
operations on the archive.
638
683
For cases where this is unwanted, you can use :mod: `copy.copy() <copy> ` or
639
684
call the :meth: `~TarInfo.replace ` method to create a modified copy in one step.
@@ -787,8 +832,8 @@ A ``TarInfo`` object has the following public data attributes:
787
832
788
833
A dictionary containing key-value pairs of an associated pax extended header.
789
834
790
- .. method :: TarInfo.replace(name=..., mtime=..., mode=..., linkname=...,
791
- uid=..., gid=..., uname=..., gname=...,
835
+ .. method :: TarInfo.replace(name=..., mtime=..., mode=..., linkname=..., \
836
+ uid=..., gid=..., uname=..., gname=..., \
792
837
deep=True)
793
838
794
839
.. versionadded :: 3.11.4
@@ -808,7 +853,7 @@ A :class:`TarInfo` object also provides some convenient query methods:
808
853
809
854
.. method :: TarInfo.isfile()
810
855
811
- Return :const: `True ` if the :class: `Tarinfo ` object is a regular file.
856
+ Return :const: `True ` if the :class: `TarInfo ` object is a regular file.
812
857
813
858
814
859
.. method :: TarInfo.isreg()
@@ -945,7 +990,7 @@ reused in custom filters:
945
990
path (after following symlinks) would end up outside the destination.
946
991
This raises :class: `~tarfile.OutsideDestinationError `.
947
992
- Clear high mode bits (setuid, setgid, sticky) and group/other write bits
948
- (:const: `~stat.S_IWGRP`| :const:`~stat.S_IWOTH `).
993
+ (:const: `~stat.S_IWGRP ` | :const: `~stat.S_IWOTH `).
949
994
950
995
Return the modified ``TarInfo `` member.
951
996
@@ -970,9 +1015,9 @@ reused in custom filters:
970
1015
- For regular files, including hard links:
971
1016
972
1017
- Set the owner read and write permissions
973
- (:const: `~stat.S_IRUSR`| :const:`~stat.S_IWUSR `).
1018
+ (:const: `~stat.S_IRUSR ` | :const: `~stat.S_IWUSR `).
974
1019
- Remove the group & other executable permission
975
- (:const: `~stat.S_IXGRP`| :const:`~stat.S_IXOTH `)
1020
+ (:const: `~stat.S_IXGRP ` | :const: `~stat.S_IXOTH `)
976
1021
if the owner doesn’t have it (:const: `~stat.S_IXUSR `).
977
1022
978
1023
- For other files (directories), set ``mode `` to ``None ``, so
0 commit comments