equal
deleted
inserted
replaced
2347 return x |
2347 return x |
2348 def flush(self): |
2348 def flush(self): |
2349 return "" |
2349 return "" |
2350 |
2350 |
2351 compressors = { |
2351 compressors = { |
2352 'UN': nocompress, |
2352 None: nocompress, |
2353 # lambda to prevent early import |
2353 # lambda to prevent early import |
2354 'BZ': lambda: bz2.BZ2Compressor(), |
2354 'BZ': lambda: bz2.BZ2Compressor(), |
2355 'GZ': lambda: zlib.compressobj(), |
2355 'GZ': lambda: zlib.compressobj(), |
2356 } |
2356 } |
|
2357 # also support the old form by courtesies |
|
2358 compressors['UN'] = compressors[None] |
2357 |
2359 |
2358 def _makedecompressor(decompcls): |
2360 def _makedecompressor(decompcls): |
2359 def generator(f): |
2361 def generator(f): |
2360 d = decompcls() |
2362 d = decompcls() |
2361 for chunk in filechunkiter(f): |
2363 for chunk in filechunkiter(f): |
2369 # Bzip2 stream start with BZ, but we stripped it. |
2371 # Bzip2 stream start with BZ, but we stripped it. |
2370 # we put it back for good measure. |
2372 # we put it back for good measure. |
2371 d.decompress('BZ') |
2373 d.decompress('BZ') |
2372 return d |
2374 return d |
2373 |
2375 |
2374 decompressors = {'UN': lambda fh: fh, |
2376 decompressors = {None: lambda fh: fh, |
2375 'BZ': _makedecompressor(_bz2), |
2377 'BZ': _makedecompressor(_bz2), |
2376 'GZ': _makedecompressor(lambda: zlib.decompressobj()), |
2378 'GZ': _makedecompressor(lambda: zlib.decompressobj()), |
2377 } |
2379 } |
|
2380 # also support the old form by courtesies |
|
2381 decompressors['UN'] = decompressors[None] |
2378 |
2382 |
2379 # convenient shortcut |
2383 # convenient shortcut |
2380 dst = debugstacktrace |
2384 dst = debugstacktrace |