本文整理汇总了Python中lzma.decompress方法的典型用法代码示例。如果您正苦于以下问题:Python lzma.decompress方法的具体用法?Python lzma.decompress怎么用?Python lzma.decompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lzma
的用法示例。
在下文中一共展示了lzma.decompress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DecompressBrotli
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def DecompressBrotli(string):
"""
DecompressBrotli(string) -> str
Returns the original form of the given string compressed \
using Google's brotli compression method., passed without delimiters.
"""
number = 0
for character in string:
ordinal = OrdinalLookup.get(character, ord(character))
number = number * 255 + ordinal - (ordinal > gap)
compressed = []
while number > 1:
compressed = [number % 256] + compressed
number //= 256
return brotli.decompress(bytes(compressed)).decode("ascii")
示例2: DecompressLZMA
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def DecompressLZMA(string):
"""
DecompressBrotli(string) -> str
Returns the original form of the given string compressed \
using Google's brotli compression method., passed without delimiters.
"""
number = 0
for character in string:
ordinal = OrdinalLookup.get(character, ord(character))
number = number * 255 + ordinal - (ordinal > gap)
compressed = []
while number > 1:
compressed = [number % 256] + compressed
number //= 256
return lzma.decompress(
bytes(compressed),
format=lzma.FORMAT_RAW,
filters=[{'id': lzma.FILTER_LZMA2, 'preset': 9 | lzma.PRESET_EXTREME}]
).decode("ascii")
示例3: __init__
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def __init__(self, file_or_filenames):
self._f = MultiFileReader(file_or_filenames)
try:
self._header = read_header(self._f)
if (self._f.size != self._header.size):
raise IncorrectFileSize(
'File size should be {0}, {1} bytes found'
.format(self._header.size, self._f.size))
except FileFormatException:
self._f.close()
raise
self._refs = RefList(self._f,
self._header.encoding,
offset=self._header.refs_offset)
self._g = MultiFileReader(file_or_filenames)
self._store = Store(self._g,
self._header.store_offset,
COMPRESSIONS[self._header.compression].decompress,
self._header.content_types)
示例4: get
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def get(self, step_id: str):
try:
cur = self.conn.cursor()
cur.execute('SELECT signature FROM steps WHERE step_id=? ',
(step_id,))
res = cur.fetchone()
except sqlite3.DatabaseError as e:
env.logger.warning(
f'Failed to get step signature for step {step_id}: {e}')
return None
if res:
try:
return pickle.loads(lzma.decompress(res[0]))
except Exception as e:
env.logger.warning(
f'Failed to load signature for step {step_id}: {e}')
return None
else:
return None
示例5: download_latest_frida
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def download_latest_frida(device: Device):
latest_release = requests.get(FRIDA_LATEST_RELEASE_URL).json()
arch = get_architecture(device)
for asset in latest_release['assets']:
release_name = asset['name']
if "server" in release_name and "android-{}.xz".format(arch) in release_name:
eprint("⚡ Downloading {}...".format(release_name))
xz_file = requests.get(asset['browser_download_url'])
eprint("⚡ Extracting {}...".format(release_name))
server_binary = lzma.decompress(xz_file.content)
eprint("⚡ Writing {}...".format(release_name))
with open(release_name[:-3], "wb") as f: # remove extension
f.write(server_binary)
return release_name[:-3]
示例6: extract_cpio
# 需要导入模块: import lzma [as 别名]
# 或者: from 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
示例7: bz2_pack
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def bz2_pack(source):
"""
Returns `source` as bzip2-compressed Python script
"""
import bz2
compressed = base64.b64encode(bz2.compress(
source.encode('utf-8'))).decode('utf-8')
return f'import bz2,base64;exec(bz2.decompress(base64.b64decode("{compressed}")))'
示例8: gz_pack
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def gz_pack(source):
"""
Returns `source` as gzip-compressed Python script
"""
import zlib
compressed = base64.b64encode(zlib.compress(source.encode('utf-8'))).decode('utf-8')
return f'import zlib,base64;exec(zlib.decompress(base64.b64decode("{compressed}")))'
示例9: lzma_pack
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def lzma_pack(source):
"""
Returns `source` as lzma-compressed Python script
"""
import lzma
compressed = base64.b64encode(lzma.compress(source.encode('utf-8'))).decode('utf-8')
return f'import lzma,base64;exec(lzma.decompress(base64.b64decode("{compressed}")))'
示例10: download_list
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def download_list(url='http://verteiler5.mediathekview.de/Filmliste-akt.xz', path='filme.json', tmp_path='filme.xz'):
print('download {}'.format(url))
with urllib.request.urlopen(url) as response, \
open(tmp_path, 'wb') as tmp_fp, \
open(path, 'wb') as fp:
data = response.read()
tmp_fp.write(data)
data = lzma.decompress(data)
fp.write(data)
示例11: decode
# 需要导入模块: import lzma [as 别名]
# 或者: from 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)
示例12: xz_decompress
# 需要导入模块: import lzma [as 别名]
# 或者: from 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
示例13: decompress
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def decompress(data, outlen):
lzma_header = struct.pack('<BIQ', PROPERTIES, DICT_SIZE, outlen)
lzma_data = lzma_header + data
decompressed = lzma.decompress(lzma_data)
return decompressed
示例14: _zlib
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def _zlib(f, size):
data = f.read(size)
return zlib.decompress(data, -zlib.MAX_WBITS)
示例15: _bzip2
# 需要导入模块: import lzma [as 别名]
# 或者: from lzma import decompress [as 别名]
def _bzip2(f, size):
from nrs.ext import bzlib
data = f.read(size)
return bytes(bzlib.decompress(data))