Created
December 23, 2013 04:58
-
-
Save Temptationx/8091806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib | |
from glob import glob | |
def zipstreams(filename): | |
"""Return all zip streams and their positions in file.""" | |
with open(filename, 'rb') as fh: | |
data = fh.read() | |
i = 0 | |
while i < len(data): | |
try: | |
zo = zlib.decompressobj() | |
yield i, zo.decompress(data[i:]) | |
i += len(data[i:]) - len(zo.unused_data) | |
except zlib.error: | |
i += 1 | |
for i, data in zipstreams('somefile'): | |
print (i, len(data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment