本文整理匯總了Python中lzma.CHECK_NONE屬性的典型用法代碼示例。如果您正苦於以下問題:Python lzma.CHECK_NONE屬性的具體用法?Python lzma.CHECK_NONE怎麽用?Python lzma.CHECK_NONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類lzma
的用法示例。
在下文中一共展示了lzma.CHECK_NONE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save_structure_to_file
# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import CHECK_NONE [as 別名]
def save_structure_to_file(structure: JsonExportable, filename: str) -> None:
"""Saves a :class:`Post`, :class:`Profile`, :class:`StoryItem` or :class:`Hashtag` to a '.json' or '.json.xz' file
such that it can later be loaded by :func:`load_structure_from_file`.
If the specified filename ends in '.xz', the file will be LZMA compressed. Otherwise, a pretty-printed JSON file
will be created.
:param structure: :class:`Post`, :class:`Profile`, :class:`StoryItem` or :class:`Hashtag`
:param filename: Filename, ends in '.json' or '.json.xz'
"""
json_structure = {'node': structure._asdict(),
'instaloader': {'version': __version__, 'node_type': structure.__class__.__name__}}
compress = filename.endswith('.xz')
if compress:
with lzma.open(filename, 'wt', check=lzma.CHECK_NONE) as fp:
json.dump(json_structure, fp=fp, separators=(',', ':'))
else:
with open(filename, 'wt') as fp:
json.dump(json_structure, fp=fp, indent=4, sort_keys=True)
示例2: _write_fileobject
# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import CHECK_NONE [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
示例3: _write_fileobject
# 需要導入模塊: import lzma [as 別名]
# 或者: from lzma import CHECK_NONE [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