Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python-list Digest, Vol 75, Issue 226

Reply
Thread Tools

Re: Python-list Digest, Vol 75, Issue 226

 
 
Gabriel Genellina
Guest
Posts: n/a
 
      12-22-2009
En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
<(E-Mail Removed)> 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.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
 
r0g
Guest
Posts: n/a
 
      12-22-2009
Gabriel Genellina wrote:
> En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
> <(E-Mail Removed)> 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...


From man gzip...


Multiple compressed files can be concatenated. In this case,
gunzip will extract all members at once. For example:

gzip -c file1 > foo.gz
gzip -c file2 >> foo.gz

Then

gunzip -c foo

is equivalent to

cat file1 file2



Roger.
 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      12-22-2009
En Tue, 22 Dec 2009 16:30:58 -0300, r0g <(E-Mail Removed)>
escribió:
> Gabriel Genellina wrote:
>> En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
>> <(E-Mail Removed)> 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

 
Reply With Quote
 
r0g
Guest
Posts: n/a
 
      12-23-2009
Gabriel Genellina wrote:
> En Tue, 22 Dec 2009 16:30:58 -0300, r0g <(E-Mail Removed)>
> escribió:
>> Gabriel Genellina wrote:
>>> En Mon, 21 Dec 2009 16:30:13 -0300, Pulkit Agrawal
>>> <(E-Mail Removed)> 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)
>



Oh I didn't see the original posting! I agree, if files within the
tarball need to be replaced (as opposed to more new files added) that
can only be done on uncompressed tar archives.

If performance is a issue and the files aren't too gargantuan it may be
best to de(and re)compress the gzips to memory/ramdisk rather than
writing it all out to disk. If the files are too large for memory but
the OP can afford a bit more storage then storing plain uncompressed
tarballs would allow use of tar's delete, replace and append
functionality. If that would take up too much space maybe they could use
plain tar on a block compressed filesystem instead.

Cheers,

Roger.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DVD Verdict reviews: TIPTOES, INSTANT BELLY DANCER: A CRASH COURSE IN BELLYDANCE, VOL.1 AND VOL. 2, and more! DVD Verdict DVD Video 0 09-24-2004 09:08 AM
Test 70-223 & 70-226 Books? Israel Lima Microsoft Certification 0 12-17-2003 06:40 PM
70-226!!! Vai2000 MCSE 1 08-31-2003 02:50 PM
Info about 226 ed MCSE 20 07-28-2003 02:55 PM
EXAM 70-226 query and interpretation? Dean Puhalovich MCSE 3 07-18-2003 01:54 PM



Advertisments