On Mon, Mar 19, 2007 at 12:06:39PM -0700, [EMAIL PROTECTED] wrote: > I have a program that generates a number of files that will be > packaged into a tarball. Can I stream the content into TarFile without > first writing them out to the file system? All add(), addfile() and > gettarinfo() seems to assume there is a file in the disk. But for me I > seems inefficient to write all the content to the disk and then have > it read back by the TarFile module.
addfile()'s fileobj argument can be anything that has a read() method. The amount of bytes to read is taken from the tarinfo.size attribute. You could let your program write its data to a StringIO object and pass that object to addfile(). http://docs.python.org/lib/tarfile-objects.html -- Lars Gustäbel [EMAIL PROTECTED] Linux is like a wigwam - no Gates, no Windows, Apache inside. -- http://mail.python.org/mailman/listinfo/python-list