• Home
  • Raw
  • Download

Lines Matching refs:tar

1 :mod:`tarfile` --- Read and write tar archive files
5 :synopsis: Read and write tar-format archive files.
14 The :mod:`tarfile` module makes it possible to read and write tar
26 * read/write support for the GNU tar format including *longname* and *longlink*
116 not allow random access, see :ref:`tar-examples`. The currently
122 | ``'r|*'`` | Open a *stream* of tar blocks for reading |
125 | ``'r|'`` | Open a *stream* of uncompressed tar blocks |
159 Class for reading and writing tar archives. Do not use this class directly:
165 Return :const:`True` if *name* is a tar archive file, that the :mod:`tarfile`
182 Is raised when a tar archive is opened, that either cannot be handled by the
217 Each of the following constants defines a tar archive format that the
218 :mod:`tarfile` module is able to create. See section :ref:`tar-formats` for
229 GNU tar format.
255 …`GNU tar manual, Basic Tar Format <https://www.gnu.org/software/tar/manual/html_node/Standard.html…
256 Documentation for tar archive files, including GNU tar extensions.
264 The :class:`TarFile` object provides an interface to a tar archive. A tar
266 a header block followed by data blocks. It is possible to store a file in a tar
274 :ref:`tar-examples` section for a use case.
328 See section :ref:`tar-unicode` for in-depth information.
472 archive. See :ref:`tar-examples` for an example.
685 with tar archives.
687 If you want to create a new tar archive, specify its name after the :option:`-c`
692 $ python -m tarfile -c monty.tar spam.txt eggs.txt
698 $ python -m tarfile -c monty.tar life-of-brian_1979/
700 If you want to extract a tar archive into the current directory, use
705 $ python -m tarfile -e monty.tar
707 You can also extract a tar archive into a different directory by passing the
712 $ python -m tarfile -e monty.tar other-dir/
714 For a list of the files in a tar archive, use the :option:`-l` option:
718 $ python -m tarfile -l monty.tar
753 How to extract an entire tar archive to the current working directory::
756 tar = tarfile.open("sample.tar.gz")
757 tar.extractall()
758 tar.close()
760 How to extract a subset of a tar archive with :meth:`TarFile.extractall` using
771 tar = tarfile.open("sample.tar.gz")
772 tar.extractall(members=py_files(tar))
773 tar.close()
775 How to create an uncompressed tar archive from a list of filenames::
778 tar = tarfile.open("sample.tar", "w")
780 tar.add(name)
781 tar.close()
786 with tarfile.open("sample.tar", "w") as tar:
788 tar.add(name)
790 How to read a gzip compressed tar archive and display some member information::
793 tar = tarfile.open("sample.tar.gz", "r:gz")
794 for tarinfo in tar:
802 tar.close()
812 tar = tarfile.open("sample.tar.gz", "w:gz")
813 tar.add("foo", filter=reset)
814 tar.close()
819 Supported tar formats
822 There are three tar formats that can be created with the :mod:`tarfile` module:
829 * The GNU tar format (:const:`GNU_FORMAT`). It supports long filenames and
831 standard on GNU/Linux systems. :mod:`tarfile` fully supports the GNU tar
836 files and stores pathnames in a portable way. Modern tar implementations,
837 including GNU tar, bsdtar/libarchive and star, fully support extended *pax*
848 There are some more variants of the tar format which can be read, but not
851 * The ancient V7 format. This is the first tar format from Unix Seventh Edition,
856 * The SunOS tar extended format. This format is a variant of the POSIX.1-2001
864 The tar format was originally conceived to make backups on tape drives with the
865 main focus on preserving file system information. Nowadays tar archives are
869 example, an ordinary tar archive created on a *UTF-8* system cannot be read