creating compressed tarfiles
Martin von Loewis
loewis at informatik.hu-berlin.de
Wed Aug 23 10:22:57 EDT 2000
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
More information about the Python-list
mailing list