Re: stringio+tarfile (or better... zipfile)

2009-07-03 Thread Gabriel Genellina
En Fri, 03 Jul 2009 17:14:22 -0300, superpollo escribió: following the excellent suggestions received, i tried to adapt the problem to zipfile, and i wrote this: zip = zipfile.ZipFile(zb , "w" , zipfile.ZIP_DEFLATED) for name , buffer in [nb1 , nb2]: zip.writestr(name, buffer.getvalue()

Re: stringio+tarfile (or better... zipfile)

2009-07-03 Thread superpollo
following the excellent suggestions received, i tried to adapt the problem to zipfile, and i wrote this: $ cat zip001.py import sys import zipfile import StringIO nb1 = "first.txt", StringIO.StringIO("one one\n") nb2 = "second.txt", StringIO.StringIO("two\n") zb = StringIO.StringIO() zip = zip

Re: stringio+tarfile

2009-07-03 Thread superpollo
Peter Otten wrote: gettarinfo() expects a real file, not a file-like object. You have to create your TarInfo manually. ok... which attributes are mandatory, and which optional? I recommend that you have a look into the tarfile module's source code. i will try... but: $ cat /usr/lib/pyt

Re: stringio+tarfile

2009-07-03 Thread Lie Ryan
superpollo wrote: >> First problem I see is all those numbers before the lines. That's not >> valid python. >> >> Assuming that was a transcription error > > not so. i intentionally add linenumbers to facilitare reference to the > code, but if it is a nuisance i will not include them anymore. Th

Re: stringio+tarfile

2009-07-03 Thread Peter Otten
superpollo wrote: > thanks to the guys who bothered to answer me even using their chrystal > ball ;-) > > i'll try to be more specific. > > yes: i want to create a tar file in memory, and add some content from a > memory buffer... > > my platform: > > $ uname -a > Linux fisso 2.4.24 #1 Thu Feb

Re: stringio+tarfile

2009-07-03 Thread superpollo
thanks to the guys who bothered to answer me even using their chrystal ball ;-) i'll try to be more specific. yes: i want to create a tar file in memory, and add some content from a memory buffer... my platform: $ uname -a Linux fisso 2.4.24 #1 Thu Feb 12 19:49:02 CET 2004 i686 GNU/Linux $ py

Re: stringio+tarfile

2009-07-03 Thread superpollo
First problem I see is all those numbers before the lines. That's not valid python. Assuming that was a transcription error not so. i intentionally add linenumbers to facilitare reference to the code, but if it is a nuisance i will not include them anymore. thanks -- http://mail.python.org

Re: stringio+tarfile

2009-07-02 Thread Dave Angel
superpollo wrote: why the following does not work? can you help me correct (if possible)? 1 import tarfile 2 import StringIO 3 sf1 = StringIO.StringIO("one\n") 4 sf2 = StringIO.StringIO("two\n") 5 tf = StringIO.StringIO() 6 tar = tarfile.open(tf , "w")

Re: stringio+tarfile

2009-07-02 Thread Gabriel Genellina
En Thu, 02 Jul 2009 17:57:49 -0300, superpollo escribió: why the following does not work? can you help me correct (if possible)? Explain "does not work" please. Does it raise an exception? Which one? Please post the complete traceback. You don't get the expected result? Tell us what did you e

stringio+tarfile

2009-07-02 Thread superpollo
why the following does not work? can you help me correct (if possible)? 1 import tarfile 2 import StringIO 3 sf1 = StringIO.StringIO("one\n") 4 sf2 = StringIO.StringIO("two\n") 5 tf = StringIO.StringIO() 6 tar = tarfile.open(tf , "w") 7 for name in [sf1 ,