Show More
@@ -2794,32 +2794,6 b' def finddirs(path):' | |||
|
2794 | 2794 | yield path[:pos] |
|
2795 | 2795 | pos = path.rfind('/', 0, pos) |
|
2796 | 2796 | |
|
2797 | # compression utility | |
|
2798 | ||
|
2799 | class nocompress(object): | |
|
2800 | def compress(self, x): | |
|
2801 | return x | |
|
2802 | def flush(self): | |
|
2803 | return "" | |
|
2804 | ||
|
2805 | compressors = { | |
|
2806 | None: nocompress, | |
|
2807 | # lambda to prevent early import | |
|
2808 | 'BZ': lambda: bz2.BZ2Compressor(), | |
|
2809 | 'GZ': lambda: zlib.compressobj(), | |
|
2810 | } | |
|
2811 | # also support the old form by courtesies | |
|
2812 | compressors['UN'] = compressors[None] | |
|
2813 | ||
|
2814 | def _makedecompressor(decompcls): | |
|
2815 | def generator(f): | |
|
2816 | d = decompcls() | |
|
2817 | for chunk in filechunkiter(f): | |
|
2818 | yield d.decompress(chunk) | |
|
2819 | def func(fh): | |
|
2820 | return chunkbuffer(generator(fh)) | |
|
2821 | return func | |
|
2822 | ||
|
2823 | 2797 | class ctxmanager(object): |
|
2824 | 2798 | '''A context manager for use in 'with' blocks to allow multiple |
|
2825 | 2799 | contexts to be entered at once. This is both safer and more |
@@ -2880,6 +2854,32 b' class ctxmanager(object):' | |||
|
2880 | 2854 | raise exc_val |
|
2881 | 2855 | return received and suppressed |
|
2882 | 2856 | |
|
2857 | # compression utility | |
|
2858 | ||
|
2859 | class nocompress(object): | |
|
2860 | def compress(self, x): | |
|
2861 | return x | |
|
2862 | def flush(self): | |
|
2863 | return "" | |
|
2864 | ||
|
2865 | compressors = { | |
|
2866 | None: nocompress, | |
|
2867 | # lambda to prevent early import | |
|
2868 | 'BZ': lambda: bz2.BZ2Compressor(), | |
|
2869 | 'GZ': lambda: zlib.compressobj(), | |
|
2870 | } | |
|
2871 | # also support the old form by courtesies | |
|
2872 | compressors['UN'] = compressors[None] | |
|
2873 | ||
|
2874 | def _makedecompressor(decompcls): | |
|
2875 | def generator(f): | |
|
2876 | d = decompcls() | |
|
2877 | for chunk in filechunkiter(f): | |
|
2878 | yield d.decompress(chunk) | |
|
2879 | def func(fh): | |
|
2880 | return chunkbuffer(generator(fh)) | |
|
2881 | return func | |
|
2882 | ||
|
2883 | 2883 | def _bz2(): |
|
2884 | 2884 | d = bz2.BZ2Decompressor() |
|
2885 | 2885 | # Bzip2 stream start with BZ, but we stripped it. |
General Comments 0
You need to be logged in to leave comments.
Login now