tar interface

Gary Herron gherron at islandtraining.com
Mon Nov 3 17:42:23 EST 2003


On Monday 03 November 2003 02:29 pm, David Bear wrote:
> I just googled for a 'python tar interface module' and got over 33000
> hits. ug.
>
> I'm looking for a python module that either interfaces to gnutar in a
> pythonic way or reads/writes tar files directly.  I know there's
> always os.popoen etc, but was hoping for something a little more ..

Python 2.3 has a module named tarfile that provides tar functionality
as well as some of the gnu extensions to tar.  It does not interface
with any external implementation of tar, put provides its own.

Here is an excerpt from its documentation:


tarfile -- Read and write tar archive files 

New in version 2.3. 

The tarfile module makes it possible to read and create tar
archives. Some facts and figures:

* reads and writes gzip and bzip2 compressed archives.

* creates POSIX 1003.1-1990 compliant or GNU tar compatible archives. 

* reads GNU tar extensions longname, longlink and sparse. 

* stores pathnames of unlimited length using GNU tar extensions. 

* handles directories, regular files, hardlinks, symbolic links,
  fifos, character devices and block devices and is able to acquire
  and restore file information like timestamp, access permissions and
  owner.

* can handle tape devices. 


Hope that works for you,

Gary Herron







More information about the Python-list mailing list