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


Python brotli.Decompressor方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def __init__(self, out: StreamReader, encoding: Optional[str]) -> None:
        self.out = out
        self.size = 0
        self.encoding = encoding
        self._started_decoding = False

        if encoding == 'br':
            if not HAS_BROTLI:  # pragma: no cover
                raise ContentEncodingError(
                    'Can not decode content-encoding: brotli (br). '
                    'Please install `brotlipy`')
            self.decompressor = brotli.Decompressor()
        else:
            zlib_mode = (16 + zlib.MAX_WBITS
                         if encoding == 'gzip' else -zlib.MAX_WBITS)
            self.decompressor = zlib.decompressobj(wbits=zlib_mode) 
開發者ID:TouwaStar,項目名稱:Galaxy_Plugin_Bethesda,代碼行數:18,代碼來源:http_parser.py

示例2: test_drip_feed

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def test_drip_feed(simple_compressed_file):
    """
    Sending in the data one byte at a time still works.
    """
    with open(simple_compressed_file[0], 'rb') as f:
        uncompressed_data = f.read()

    with open(simple_compressed_file[1], 'rb') as f:
        compressed_data = f.read()

    outdata = []
    o = brotli.Decompressor()
    for i in range(0, len(compressed_data)):
        outdata.append(o.decompress(compressed_data[i:i+1]))

    outdata.append(o.flush())
    outdata.append(o.finish())

    assert b''.join(outdata) == uncompressed_data 
開發者ID:python-hyper,項目名稱:brotlipy,代碼行數:21,代碼來源:test_simple_decompression.py

示例3: __init__

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def __init__(self):
            self._obj = brotli.Decompressor() 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:4,代碼來源:response.py

示例4: gzip_decompressor

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def gzip_decompressor():
    """
    Decompressor which can handle decompress gzip stream
    """
    return zlib.decompressobj(16 + zlib.MAX_WBITS) 
開發者ID:webrecorder,項目名稱:warcio,代碼行數:7,代碼來源:bufferedreaders.py

示例5: try_brotli_init

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def try_brotli_init():
    try:
        import brotli

        def brotli_decompressor():
            decomp = brotli.Decompressor()
            decomp.unused_data = None
            return decomp

        BufferedReader.DECOMPRESSORS['br'] = brotli_decompressor
    except ImportError:  #pragma: no cover
        pass


#================================================================= 
開發者ID:webrecorder,項目名稱:warcio,代碼行數:17,代碼來源:bufferedreaders.py

示例6: test_decompressobj

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def test_decompressobj(simple_compressed_file):
    with open(simple_compressed_file[0], 'rb') as f:
        uncompressed_data = f.read()

    with open(simple_compressed_file[1], 'rb') as f:
        compressed_data = f.read()

    o = brotli.Decompressor()
    data = o.decompress(compressed_data)
    data += o.flush()
    data += o.finish()

    assert data == uncompressed_data 
開發者ID:python-hyper,項目名稱:brotlipy,代碼行數:15,代碼來源:test_simple_decompression.py

示例7: test_streaming_decompression_fails_properly_on_garbage

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def test_streaming_decompression_fails_properly_on_garbage(exception_cls):
    """
    Garbage data properly fails decompression.
    """
    o = brotli.Decompressor()
    with pytest.raises(exception_cls):
        o.decompress(b'some random garbage') 
開發者ID:python-hyper,項目名稱:brotlipy,代碼行數:9,代碼來源:test_simple_decompression.py

示例8: test_compressed_data_with_dictionaries

# 需要導入模塊: import brotli [as 別名]
# 或者: from brotli import Decompressor [as 別名]
def test_compressed_data_with_dictionaries(s, dictionary):
    d = brotli.Decompressor(dictionary)
    compressed = brotli.compress(s, dictionary=dictionary)
    uncompressed = d.decompress(compressed)
    assert uncompressed == s 
開發者ID:python-hyper,項目名稱:brotlipy,代碼行數:7,代碼來源:test_simple_compression.py


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