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


Python lzma.FORMAT_ALONE屬性代碼示例

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


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

示例1: _write_fileobject

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FORMAT_ALONE [as 別名]
def _write_fileobject(filename, compress=("zlib", 3)):
    """Return the right compressor file object in write mode."""
    compressmethod = compress[0]
    compresslevel = compress[1]
    if compressmethod == "gzip":
        return _buffered_write_file(BinaryGzipFile(filename, 'wb',
                                    compresslevel=compresslevel))
    elif compressmethod == "bz2" and bz2 is not None:
        return _buffered_write_file(bz2.BZ2File(filename, 'wb',
                                                compresslevel=compresslevel))
    elif lzma is not None and compressmethod == "xz":
        return _buffered_write_file(lzma.LZMAFile(filename, 'wb',
                                                  check=lzma.CHECK_NONE,
                                                  preset=compresslevel))
    elif lzma is not None and compressmethod == "lzma":
        return _buffered_write_file(lzma.LZMAFile(filename, 'wb',
                                                  preset=compresslevel,
                                                  format=lzma.FORMAT_ALONE))
    else:
        return _buffered_write_file(BinaryZlibFile(filename, 'wb',
                                    compresslevel=compresslevel))


###############################################################################
#  Joblib zlib compression file object definition 
開發者ID:flennerhag,項目名稱:mlens,代碼行數:27,代碼來源:numpy_pickle_utils.py

示例2: _write_fileobject

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FORMAT_ALONE [as 別名]
def _write_fileobject(filename, compress=("zlib", 3)):
    """Return the right compressor file object in write mode."""
    compressmethod = compress[0]
    compresslevel = compress[1]
    if compressmethod == "gzip":
        return _buffered_write_file(BinaryGzipFile(filename, 'wb',
                                    compresslevel=compresslevel))
    elif compressmethod == "bz2":
        return _buffered_write_file(bz2.BZ2File(filename, 'wb',
                                                compresslevel=compresslevel))
    elif lzma is not None and compressmethod == "xz":
        return _buffered_write_file(lzma.LZMAFile(filename, 'wb',
                                                  check=lzma.CHECK_NONE,
                                                  preset=compresslevel))
    elif lzma is not None and compressmethod == "lzma":
        return _buffered_write_file(lzma.LZMAFile(filename, 'wb',
                                                  preset=compresslevel,
                                                  format=lzma.FORMAT_ALONE))
    else:
        return _buffered_write_file(BinaryZlibFile(filename, 'wb',
                                    compresslevel=compresslevel))


###############################################################################
#  Joblib zlib compression file object definition 
開發者ID:bbfamily,項目名稱:abu,代碼行數:27,代碼來源:numpy_pickle_utils.py

示例3: __init__

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FORMAT_ALONE [as 別名]
def __init__(self):
    """Initializes a decompressor."""
    super(LZMADecompressor, self).__init__()
    # Note that lzma.FORMAT_ALONE does not work for every implementation
    # of lzma.
    self._lzma_decompressor = lzma.LZMADecompressor(2) 
開發者ID:log2timeline,項目名稱:dfvfs,代碼行數:8,代碼來源:xz_decompressor.py

示例4: encode_file

# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import FORMAT_ALONE [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.FORMAT_ALONE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。