tarfile.TarFile

class tarfile.TarFile(name=None, mode='r', fileobj=None, format=None, tarinfo=None, dereference=None, ignore_zeros=None, encoding=None, errors=None, pax_headers=None, debug=None, errorlevel=None)[source]

The TarFile Class provides an interface to tar archives.

Methods

__enter__()
__exit__(type, value, traceback)
__format__ default object formatter
__init__([name, mode, fileobj, format, ...]) Open an (uncompressed) tar archive `name’.
__iter__() Provide an iterator object.
__new__((S, ...)
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__sizeof__(() -> int) size of object in memory, in bytes
__subclasshook__ Abstract classes can override this to customize issubclass().
_check([mode]) Check if TarFile is still open, and if the operation’s mode corresponds to TarFile’s mode.
_dbg(level, msg) Write debugging output to sys.stderr.
_extract_member(tarinfo, targetpath) Extract the TarInfo object tarinfo to a physical file called targetpath.
_find_link_target(tarinfo) Find the target member of a symlink or hardlink member in the archive.
_getmember(name[, tarinfo, normalize]) Find an archive member by name from bottom to top.
_getposix()
_load() Read through the entire archive file and look for readable members.
_setposix(value)
add(name[, arcname, recursive, exclude, filter]) Add the file `name’ to the archive.
addfile(tarinfo[, fileobj]) Add the TarInfo object `tarinfo’ to the archive.
bz2open(name[, mode, fileobj, compresslevel]) Open bzip2 compressed tar archive name for reading or writing.
chmod(tarinfo, targetpath) Set file permissions of targetpath according to tarinfo.
chown(tarinfo, targetpath) Set owner of targetpath according to tarinfo.
close() Close the TarFile.
extract(member[, path]) Extract a member from the archive to the current working directory, using its full name.
extractall([path, members]) Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards.
extractfile(member) Extract a member from the archive as a file object.
getmember(name) Return a TarInfo object for member `name’.
getmembers() Return the members of the archive as a list of TarInfo objects.
getnames() Return the members of the archive as a list of their names.
gettarinfo([name, arcname, fileobj]) Create a TarInfo object from the result of os.stat or equivalent on an existing file.
gzopen(name[, mode, fileobj, compresslevel]) Open gzip compressed tar archive name for reading or writing.
list([verbose]) Print a table of contents to sys.stdout.
makedev(tarinfo, targetpath) Make a character or block device called targetpath.
makedir(tarinfo, targetpath) Make a directory called targetpath.
makefifo(tarinfo, targetpath) Make a fifo called targetpath.
makefile(tarinfo, targetpath) Make a file called targetpath.
makelink(tarinfo, targetpath) Make a (symbolic) link called targetpath.
makeunknown(tarinfo, targetpath) Make a file from a TarInfo object with an unknown type at targetpath.
next() Return the next member of the archive as a TarInfo object, when TarFile is opened for reading.
open([name, mode, fileobj, bufsize]) Open a tar archive for reading, writing or appending.
taropen(name[, mode, fileobj]) Open uncompressed tar archive name for reading or writing.
utime(tarinfo, targetpath) Set modification time of targetpath according to tarinfo.