当前位置: 首页>>代码示例>>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;未经允许,请勿转载。