Python equivalent of Archive::Tar?

Tom Robinson tom at alkali.spamfree.org
Mon Aug 13 11:22:18 EDT 2001


On Mon, 13 Aug 2001 15:32:40 +0100, Tom Robinson
<tom at alkali.spamfree.org> wrote:

>Is there a python equivalent of this perl module?  I specifically want
>to be able to create a tar file in memory by reading in the files for
>it and then write it out to a web browser.  I've managed to acheive
>this in perl by using Archive::Tar, has anyone written a similar
>library for python?  I had a quick search but "tar" always turns up a
>huge amount of unwanted results. :)

It appears I wasn't looking hard enough, see below.  I've managed to
get tar.py in Zope to work, but it doesn't have the generality of
Archive::Tar obviously.  Maybe I'll use the Zope code as a base for a
python version...

From: Martin von Loewis (loewis at informatik.hu-berlin.de)
Subject: Re: creating compressed tarfiles 
Newsgroups: comp.lang.python
Date: 2000/08/23 

>thomas at cintra.no (Tw) writes:
>
>> How can I create compressed tarfiles, ie. lots of files inside a
>> compressed file, using either the tarlib.py or tar.py ( found in Zope
>> ) and gzip and/or zlib? 
>> 
>> I need examples.
>
>Without trying, it appears that Zope's tar.py already handles
>compressed files.
>
>Let names contain a list of all files to add, I'd say the following
>might work:
>
>archive = tar.tgzarchive("foo")
>for n in names:
>  data = open(n).read()
>  archive.add(n, data)
>archive.finish()
>open("foo.tgz").write(archive)
>
>It appears as if this would keep the compressed file in memory,
>though; there is apparently no streaming tar library.
>
>Regards,
>Martin

-- 
tom at alkali.spamfree.org
remove 'spamfree.' to respond



More information about the Python-list mailing list