The TarFile object provides an interface to a tar archive. A tar archive is a sequence of blocks. An archive member (a stored file) is made up of a header block followed by data blocks. It is possible, to store a file in a tar archive several times. Each archive member is represented by a TarInfo object, see TarInfo Objects (section 7.19.2) for details.
[name [, mode[, fileobj]]]) |
'r'
to read from an existing archive,
'a'
to append data to an existing file or 'w'
to create a new
file overwriting an existing one. mode defaults to 'r'
.
If fileobj is given, it is used for reading or writing data. If it can be determined, mode is overridden by fileobj's mode.
...) |
name) |
) |
) |
verbose=True) |
sys.stdout
. If verbose is
False
, only the names of the members are printed. If it is
True
, an "ls -l"
-like output is produced.
) |
None
if there is no
more available.
member[, path]) |
member) |
None
is returned.
name[, arcname[, recursive=True]]) |
False
.
tarinfo[, fileobj]) |
tarinfo.size
bytes are read
from it and added to the archive. You can create TarInfo objects
using gettarinfo().
'rb'
to avoid irritation about the file size.
[name[, arcname [, fileobj]]]) |
os.fstat()
on its file descriptor).
You can modify some of the TarInfo's attributes before you add it
using addfile().
If given, arcname specifies an alternative name for the file in the
archive.
) |
True
, create a POSIX 1003.1-1990 compliant archive. GNU
extensions are not used, because they are not part of the POSIX standard.
This limits the length of filenames to at most 256 and linknames to 100
characters. A ValueError is raised, if a pathname exceeds this
limit.
If False
, create a GNU tar compatible archive. It will not be POSIX
compliant, but can store pathnames of unlimited length.
False
, add symbolic and hard links to archive. If True
,
add the content of the target files to the archive. This has no effect on
systems that do not support links.
False
, treat an empty block as the end of the archive. If
True
, skip empty (and invalid) blocks and try to get as many
members as possible. This is only useful for concatenated or damaged
archives.
0
(no debug messages) up to 3
(all debug
messages). The messages are written to sys.stdout
.
0
, all errors are ignored when using extract().
Nevertheless, they appear as error messages in the debug output, when
debugging is enabled.
If 1
, all fatal errors are raised as OSError
or IOError exceptions.
If 2
, all non-fatal errors are raised as TarError
exceptions as well.
See About this document... for information on suggesting changes.