12.5.2 TarInfo Objects
A TarInfo object represents one member in a
TarFile. Aside from storing all required attributes of a file
(like file type, size, time, permissions, owner etc.), it provides
some useful methods to determine its type. It does not contain
the file's data itself.
TarInfo objects are returned by TarFile's methods
getmember(), getmembers() and gettarinfo().
-
Create a TarInfo object.
-
Create and return a TarInfo object from a string buffer.
-
Create a string buffer from a TarInfo object.
See TarFile's posix attribute for information
on the posix argument. It defaults to False.
New in version 2.5:
The posix parameter.
A TarInfo
object has the following public data attributes:
- name
-
Name of the archive member.
- size
-
Size in bytes.
- mtime
-
Time of last modification.
- mode
-
Permission bits.
- type
-
File type. type is usually one of these constants:
REGTYPE, AREGTYPE, LNKTYPE,
SYMTYPE, DIRTYPE, FIFOTYPE,
CONTTYPE, CHRTYPE, BLKTYPE,
GNUTYPE_SPARSE. To determine the type of a
TarInfo object more conveniently, use the
is_*()
methods below.
- linkname
-
Name of the target file name, which is only present in
TarInfo objects of type LNKTYPE and
SYMTYPE.
- uid
-
User ID of the user who originally stored this member.
- gid
-
Group ID of the user who originally stored this member.
- uname
-
User name.
- gname
-
Group name.
A TarInfo object also provides some convenient query methods:
-
Return True if the Tarinfo object is a regular
file.
-
Same as isfile().
-
Return True if it is a directory.
-
Return True if it is a symbolic link.
-
Return True if it is a hard link.
-
Return True if it is a character device.
-
Return True if it is a block device.
-
Return True if it is a FIFO.
-
Return True if it is one of character device, block
device or FIFO.
Release 2.5, documentation updated on 19th September, 2006.
See About this document... for information on suggesting changes.