4

I have to deal with a "proprietary" file format that's nothing more than a bunch of text files, which each has been gzip'd, then encrypted, and then finally all of them bundled in a zip file. I'm using python to automate the extraction of these files. So the unzipping is easy with ZipFile. Then I have a list of xyz_001.gz.rc4 files which I can decrypt with RC4 + key. Then, however, that leaves me with a gz stream, and cannot use gzip standard library module to open that stream. I suppose I could store that stream to disk and then open that gz file, but I was wondering if there was a more graceful way to handle it.

Help is much appreciated.

1 Answer 1

4

You can use the zlib module to decompress a gzip stream, with something like:

zlib.decompress(inf, 16+zlib.MAX_WBITS)

where inf is your gzip stream. The 16 + zlib.MAX_WBITS is a magic value that makes zlib skip over the gzip header.

1
  • Looks promising, let me give it a try real quick. Thanks for prompt reply.
    – rdodev
    Commented Apr 11, 2012 at 19:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.