xz_mod module¶
Impersonate the real xz module, which has yet to be written and/or added to CPython, by using the xz binary.
- exception xz_mod.DecompressionError[source]¶
Bases:
Exception
An exception to raise if there is a problem decompressing data. Should be rare but not nonexistent in practice.
- class xz_mod.Xz_ctypes[source]¶
Bases:
object
A class to compress and decompress xz format, using ctypes to access liblzma.
- LZMA_BUF_ERROR = 10¶
- LZMA_CHECK_CRC32 = 1¶
- LZMA_DATA_ERROR = 9¶
- LZMA_FORMAT_ERROR = 7¶
- LZMA_LIB = <CDLL 'liblzma.so.5', handle 25b1930>¶
- LZMA_LIBPATH = 'liblzma.so.5'¶
- LZMA_MEMLIMIT_ERROR = 6¶
- LZMA_MEM_ERROR = 5¶
- LZMA_NO_CHECK = 2¶
- LZMA_OK = 0¶
- LZMA_OPTIONS_ERROR = 8¶
- LZMA_PRESET_DEFAULT = 6¶
- LZMA_PROG_ERROR = 11¶
- LZMA_TELL_NO_CHECK = 1¶
- LZMA_TELL_UNSUPPORTED_CHECK = 2¶
- LZMA_UNSUPPORTED_CHECK = 3¶
- classmethod compress(input_data)[source]¶
Compress data into xz format using ctypes to access liblzma.so.
- classmethod declare_c_function(library, name, argtypes=None, restype=None)[source]¶
Extract functions from liblzma.
- classmethod decompress(input_data, max_result_size=67108864)[source]¶
Uncompress data from xz format using ctypes to access liblzma.so.
- error_dict = {0: 'LZMA_OK', 1: 'LZMA_TELL_NO_CHECK', 2: 'LZMA_TELL_UNSUPPORTED_CHECK', 3: 'LZMA_UNSUPPORTED_CHECK', 5: 'LZMA_MEM_ERROR', 6: 'LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. minimum required memlimit value was stored to *memlimit', 7: "LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given buffer cannot be Stream Header.", 8: 'LZMA_OPTIONS_ERROR', 9: 'LZMA_DATA_ERROR', 10: 'LZMA_BUF_ERROR: Output buffer was too small', 11: 'LZMA_PROG_ERROR'}¶
- funcs = {'lzma_easy_buffer_encode': <_FuncPtr object>, 'lzma_stream_buffer_bound': <_FuncPtr object>, 'lzma_stream_buffer_decode': <_FuncPtr object>}¶
- classmethod get_xz_error(ret_xz)[source]¶
Decode an lzma_ret enum to an at-least-somewhat-descriptive string.
- long_message = 'LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. minimum required memlimit value was stored to *memlimit'¶
- long_string = "LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given buffer cannot be Stream Header."¶