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()
|
A TarInfo
object has the following public data attributes:
please, read my previous module Library Tarfile. In which I have discussed all the attributes.
* 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.
import tarfile def hello(tar): for tarinfo in tar: print (tarinfo.name, "is", tarinfo.size, "bytes in size and is",) if tarinfo.isreg(): print ("a regular file.") elif tarinfo.isdir(): print ("a directory.") else: print ("something else.") tar.close() tar = tarfile.open("phayes-geoPHP-1.2-20-g6855624.tar.gz", "r:gz") hello(tar)
Name | Views | Likes |
---|---|---|
Python project_Speech to text | 478 | 3 |
Tarfile_Metadata | 378 | 6 |
Library_Tarfile | 631 | 5 |
python project_color detection | 538 | 3 |
Text to Speech using Python | 445 | 6 |
Tarfile_TarInfo Objects | 313 | 5 |
Tarfile_Extracting file from Archive | 264 | 3 |
Tarfile_generator function | 295 | 3 |
tarfile_targzstream | 259 | 7 |
Tarfile_Exception | 643 | 5 |
python Project_Detecting Fake news | 773 | 3 |
Tarfile_working with compressed archives | 328 | 5 |
Tarfile_Objects | 367 | 5 |
Project in python_color detection | 76 | 1 |
Tarfile_Archive Access | 342 | 5 |
Comments