当前位置: 首页>>代码示例>>Python>>正文


Python lzma.decompress方法代码示例

本文整理汇总了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) 
开发者ID:zarr-developers,项目名称:numcodecs,代码行数:14,代码来源:lzma.py

示例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 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:10,代码来源:rpm2cpio.py

示例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 
开发者ID:milisarge,项目名称:malfs-milis,代码行数:17,代码来源:rpm2cpio.py

示例4: uncompress

# 需要导入模块: from backports import lzma [as 别名]
# 或者: from backports.lzma import decompress [as 别名]
def uncompress(self, src):
		import zlib
		return zlib.decompress(src) 
开发者ID:seekintoo,项目名称:Chimay-Red,代码行数:5,代码来源:PySquashfsImage.py

示例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)) 
开发者ID:scikit-hep,项目名称:uproot,代码行数:40,代码来源:compressed.py


注:本文中的backports.lzma.decompress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。