當前位置: 首頁>>代碼示例>>Python>>正文


Python lzma.FILTER_LZMA1屬性代碼示例

本文整理匯總了Python中lzma.FILTER_LZMA1屬性的典型用法代碼示例。如果您正苦於以下問題:Python lzma.FILTER_LZMA1屬性的具體用法?Python lzma.FILTER_LZMA1怎麽用?Python lzma.FILTER_LZMA1使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在lzma的用法示例。


在下文中一共展示了lzma.FILTER_LZMA1屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: decompress

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FILTER_LZMA1 [as 別名]
def decompress(self, buf):
		if not self.compressed:
			return buf
		ty = self.compression_type
		if ty == CompressionType.LZMA:
			props, dict_size = struct.unpack("<BI", buf.read(5))
			lc = props % 9
			props = int(props / 9)
			pb = int(props / 5)
			lp = props % 5
			dec = lzma.LZMADecompressor(format=lzma.FORMAT_RAW, filters=[{
				"id": lzma.FILTER_LZMA1,
				"dict_size": dict_size,
				"lc": lc,
				"lp": lp,
				"pb": pb,
			}])
			res = dec.decompress(buf.read())
			return BytesIO(res)
		if ty in (CompressionType.LZ4, CompressionType.LZ4HC):
			res = lz4_decompress(buf.read(self.compressed_size), self.uncompressed_size)
			return BytesIO(res)
		raise NotImplementedError("Unimplemented compression method: %r" % (ty)) 
開發者ID:HearthSim,項目名稱:UnityPack,代碼行數:25,代碼來源:assetbundle.py

示例2: get_coder

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FILTER_LZMA1 [as 別名]
def get_coder(cls, filter) -> Dict[str, Any]:
        method = cls.get_method_id(filter)
        if filter['id'] in [lzma.FILTER_LZMA1, lzma.FILTER_LZMA2, lzma.FILTER_DELTA]:
            properties = lzma._encode_filter_properties(filter)  # type: Optional[bytes] # type: ignore  # noqa
        else:
            properties = None
        return {'method': method, 'properties': properties, 'numinstreams': 1, 'numoutstreams': 1} 
開發者ID:miurahr,項目名稱:py7zr,代碼行數:9,代碼來源:compressor.py

示例3: test_lzmadecompressor_lzmabcj

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FILTER_LZMA1 [as 別名]
def test_lzmadecompressor_lzmabcj():
    indata = b'This file is located in the root.'
    compressor = lzma.LZMACompressor(format=lzma.FORMAT_RAW,
                                     filters=[{'id': lzma.FILTER_X86}, {'id': lzma.FILTER_LZMA1}])
    compressed = compressor.compress(indata)
    compressed += compressor.flush()
    decompressor = lzma.LZMADecompressor(format=lzma.FORMAT_RAW,
                                         filters=[{'id': lzma.FILTER_X86}, {'id': lzma.FILTER_LZMA1}])
    outdata = decompressor.decompress(data=compressed)
    assert outdata == indata 
開發者ID:miurahr,項目名稱:py7zr,代碼行數:12,代碼來源:test_unit.py

示例4: __init__

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FILTER_LZMA1 [as 別名]
def __init__(self, preset=None, compress_options=None):
			super().__init__()

			if compress_options is None:
				compress_options = {}
			if (compress_options.setdefault("id", lzma.FILTER_LZMA1)
				!= lzma.FILTER_LZMA1
			):
				raise ValueError(
					"Illegal LZMA filter ID: " + repr(compress_options["id"]))
			if preset is not None:
				compress_options["preset"] = preset
			self.compress_options = compress_options 
開發者ID:davidfoerster,項目名稱:aptsources-cleanup,代碼行數:15,代碼來源:zip.py

示例5: encode_file

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FILTER_LZMA1 [as 別名]
def encode_file(path, max_len=4):
    basename = os.path.splitext(path)[0]
    encodedname = basename + ".encoded.csv"

    print("process:", path, "->", encodedname)

    with open(path, 'rb') as f:
        data = f.read()

    filters = [
        {
            "id": lzma.FILTER_LZMA1,
            "dict_size": 256 * 1024,
            "lc": 3,
            "lp": 0,
            "pb": 2,
            "mode": lzma.MODE_NORMAL
        },
    ]

    pack_data = lzma.compress(data, format=lzma.FORMAT_ALONE, filters=filters)

    lzmadata = bytearray()

    for i in range(0, 5):
        lzmadata.append(pack_data[i])

    data_size = len_2_bytes(len(data), max_len)
    for size in data_size:
        lzmadata.append(size)

    for i in range(13, len(pack_data)):
        lzmadata.append(pack_data[i])

    #for i in range(0, len(lzmadata)):
    #    print("i: ", i, " val: ", lzmadata[i])

    with open(encodedname, 'wb') as f:
        f.write(lzmadata)

#
# restore_file
# 
開發者ID:proydakov,項目名稱:supercell_resource_decoder,代碼行數:45,代碼來源:lib_csv.py


注:本文中的lzma.FILTER_LZMA1屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。