how to gunzip a string ?
lorenb2 at bezeqint.net
Thu Jul 31 11:11:28 CEST 2003
Thanks !!! it works fine.
question: upon calling GzipConsumer's close methos, it in turn invokes a
consumer close method, too.
on the stupid_consumer you demonstrated there is no such method. the
question is whether an extremely_stupid
"def close(self): pass" method is just fine or is there something important
to do with the data ?
----- Original Message -----
From: "Fredrik Lundh" <fredrik at pythonware.com>
To: <python-list at python.org>
Sent: Wednesday, July 30, 2003 7:47 PM
Subject: Re: how to gunzip a string ?
> Bill Loren wrote:
> > I guess I really need some sort of library that will do a gzip decoding
> > compressed string.
> > assume that I have a gzipped_string_reply I got from an HTTP server,
> > It'd be superb to have a gunzip class that takes it and return its
> > equivalent.
> > I managed to do it with the gzip library only after saving the string to
> > file and then opening and reading it
> > with gzip.open, but it's extremely ugly.
> > any suggestions ?
> trying again:
> (GzipConsumer module)
> interface code (based on john j. lee's posting):
> from GzipConsumer import GzipConsumer
> class stupid_gzip_consumer:
> def __init__(self): self.data = 
> def feed(self, data): self.data.append(data)
> def gunzip(data):
> c = stupid_gzip_consumer()
> gzc = GzipConsumer(c)
> return "".join(c.data)
> unzipped_data = gunzip(gzipped_data)
More information about the Python-list