Python-list Digest, Vol 75, Issue 226

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Dec 22 18:46:40 EST 2009


En Tue, 22 Dec 2009 16:30:58 -0300, r0g <aioe.org at technicalbloke.com>  
escribió:
> Gabriel Genellina wrote:
>> En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
>> <thatguypulkit at gmail.com> escribió:
>>
>>> I am writing a script wherein I need to merge files into existing  
>>> tar.gz
>>> files. Currently, I am using tarfile module. I extract the tar.gz to a
>>> tempdir and copy the new file there and re-compress all the files back
>>> into
>>> a tar.gz.  Is there a better way to do it?
>>
>> Since noone answered yet: no, I don't think you can avoid to decompress
>> and recompress those files.
>
> Erm, I always thought it was OK to simply cat gzipped files together...

Maybe, but still I don't think this could help the OP. As I understand the  
problem, originally there were e.g.: file1, file2, file3; they were tarred  
into file123.tar and gzipped into file123.tar.gz. And now file2 must be  
replaced by a newer version. It should go into the internal .tar file,  
replacing the old one; I don't see how to do that without decompressing  
it. (Ok, once the tar is decompressed one might replace the old file with  
the newer one in-place using the tar command, but this cannot be done with  
the tarfile Python module)

-- 
Gabriel Genellina




More information about the Python-list mailing list