handling tar, gz and bz2 with python

M

Matthew Thorley

Is there a module for unpacking tar files in python? how about bzip2 and
gzips? I know I can use the gzip module for gzips but is there anything
that can detect what format a file is in and decopress and unpack it
using the other methods?

thanks
-Matthew
 
F

Fredrik Lundh

Matthew said:
Is there a module for unpacking tar files in python?
...
| open(cls, name=None, mode='r', fileobj=None, bufsize=10240) from __built
in__.type
| 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
|
| taropen(cls, name, mode='r', fileobj=None) from __builtin__.type
| Open uncompressed tar archive name for reading or writing.
...
how about bzip2 and gzips? I know I can use the gzip module for gzips
but is there anything that can detect what format a file is in and decopress
and unpack it using the other methods?

see above.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top