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


Python lzma.decompress方法代碼示例

本文整理匯總了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") 
開發者ID:somebody1234,項目名稱:Charcoal,代碼行數:18,代碼來源:compression.py

示例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") 
開發者ID:somebody1234,項目名稱:Charcoal,代碼行數:22,代碼來源:compression.py

示例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) 
開發者ID:itkach,項目名稱:slob,代碼行數:24,代碼來源:slob.py

示例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 
開發者ID:vatlab,項目名稱:sos,代碼行數:21,代碼來源:signatures.py

示例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] 
開發者ID:Hamz-a,項目名稱:frida-android-helper,代碼行數:19,代碼來源:server.py

示例6: 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}")))' 
開發者ID:PyObfx,項目名稱:PyObfx,代碼行數:9,代碼來源:packer.py

示例7: 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 
開發者ID:milisarge,項目名稱:malfs-milis,代碼行數:17,代碼來源:rpm2cpio.py

示例8: 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}")))' 
開發者ID:PyObfx,項目名稱:PyObfx,代碼行數:10,代碼來源:packer.py

示例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}")))' 
開發者ID:PyObfx,項目名稱:PyObfx,代碼行數:9,代碼來源:packer.py

示例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) 
開發者ID:hcmlab,項目名稱:vadnet,代碼行數:14,代碼來源:playlist.py

示例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) 
開發者ID:zarr-developers,項目名稱:numcodecs,代碼行數:14,代碼來源:lzma.py

示例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 
開發者ID:milisarge,項目名稱:malfs-milis,代碼行數:10,代碼來源:rpm2cpio.py

示例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 
開發者ID:sviehb,項目名稱:jefferson,代碼行數:7,代碼來源:jffs2_lzma.py

示例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) 
開發者ID:isra17,項目名稱:nrs,代碼行數:5,代碼來源:fileform.py

示例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)) 
開發者ID:isra17,項目名稱:nrs,代碼行數:6,代碼來源:fileform.py


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