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()
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
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
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
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
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
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
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")
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
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 ,
10 matches
Mail list logo