tarfile woes
Gustavo Niemeyer
niemeyer at conectiva.com
Thu Aug 21 17:20:20 EDT 2003
> - bzip2 compressed files cannot be read from a "fake" (StringIO) file
> object, only from real files. This is (imho) unbelievably ugly, as
> I have the file already in a string. I really do not want to read it
> a second time. Or a third time, when the user finally decides that
> she wants the archive actually unpacked (second was TOC listing).
>
> - It does not handle compressed (.Z) archives. Of course there's
> noone to blame. The gzip utility (which is used by gnu tar) handles
> this ancient algorithm, but apparently, zlib does not. :-(
>>> import bz2
>>> print bz2.decompress.__doc__
decompress(data) -> decompressed data
Decompress data in one shot. If you want to decompress data
sequentially, use an instance of BZ2Decompressor instead.
>>> import gzip
>>> print gzip.__doc__
Functions that read and write gzipped files.
The user of the file doesn't have to worry about the compression,
but random access is not allowed.
>>> import tarfile
>>> print tarfile.open.__doc__
Open a tar archive for reading, writing or appending. Return
an appropriate TarFile class.
mode:
'r' open for reading with transparent compression
'r:' open for reading exclusively uncompressed
'r:gz' open for reading with gzip compression
'r:bz2' open for reading with bzip2 compression
'a' or 'a:' open for appending
'w' or 'w:' open for writing without compression
'w:gz' open for writing with gzip compression
'w:bz2' open for writing with bzip2 compression
'r|' open an uncompressed stream of tar blocks for reading
'r|gz' open a gzip compressed stream of tar blocks
'r|bz2' open a bzip2 compressed stream of tar blocks
'w|' open an uncompressed stream for writing
'w|gz' open a gzip compressed stream for writing
'w|bz2' open a bzip2 compressed stream for writing
--
Gustavo Niemeyer
http://niemeyer.net
More information about the Python-list
mailing list