本文整理汇总了Python中backports.lzma.decompress方法的典型用法代码示例。如果您正苦于以下问题:Python lzma.decompress方法的具体用法?Python lzma.decompress怎么用?Python lzma.decompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backports.lzma
的用法示例。
在下文中一共展示了lzma.decompress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: decode
# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def decode(self, buf, out=None):
# normalise inputs
buf = ensure_contiguous_ndarray(buf)
if out is not None:
out = ensure_contiguous_ndarray(out)
# do decompression
dec = _lzma.decompress(buf, format=self.format, filters=self.filters)
# handle destination
return ndarray_copy(dec, out)
示例2: xz_decompress
# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def xz_decompress(data):
if HAS_LZMA_MODULE:
return lzma.decompress(data)
unxz = subprocess.Popen(['unxz'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
data = unxz.communicate(input=data)[0]
return data
示例3: extract_cpio
# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def extract_cpio(reader):
data = reader.read()
decompress = None
idx = data.find(XZ_MAGIC)
if idx != -1:
decompress = xz_decompress
pos = idx
idx = data.find(GZIP_MAGIC)
if idx != -1 and decompress is None:
decompress = gzip_decompress
pos = idx
if decompress is None:
return None
data = decompress(data[pos:])
return data
示例4: uncompress
# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def uncompress(self, src):
import zlib
return zlib.decompress(src)
示例5: decompress
# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def decompress(self, source, cursor, compressedbytes, uncompressedbytes=None):
if self.algo == uproot.const.kZLIB:
from zlib import decompress as zlib_decompress
return zlib_decompress(cursor.bytes(source, compressedbytes))
elif self.algo == uproot.const.kLZMA:
try:
from lzma import decompress as lzma_decompress
except ImportError:
try:
from backports.lzma import decompress as lzma_decompress
except ImportError:
raise ImportError("install lzma package with:\n pip install backports.lzma\nor\n conda install backports.lzma\n(or just use Python >= 3.3).")
return lzma_decompress(cursor.bytes(source, compressedbytes))
elif self.algo == uproot.const.kOldCompressionAlgo:
raise NotImplementedError("ROOT's \"old\" algorithm (fCompress 300) is not supported")
elif self.algo == uproot.const.kLZ4:
try:
from lz4.block import decompress as lz4_decompress
except ImportError:
raise ImportError("install lz4 package with:\n pip install lz4\nor\n conda install lz4")
if uncompressedbytes is None:
raise ValueError("lz4 needs to know the uncompressed number of bytes")
return lz4_decompress(cursor.bytes(source, compressedbytes), uncompressed_size=uncompressedbytes)
elif self.algo == uproot.const.kZSTD:
try:
import zstandard as zstd
except ImportError:
raise ImportError("install zstd package with:\n pip install zstandard\nor\n conda install zstandard")
dctx = zstd.ZstdDecompressor()
return dctx.decompress(cursor.bytes(source, compressedbytes))
else:
raise ValueError("unrecognized compression algorithm: {0}".format(self.algo))