Python brotli.Decompressor() Examples

The following are 30 code examples of brotli.Decompressor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module brotli , or try the search function .
Example #1
Source File: http_parser.py    From Galaxy_Plugin_Bethesda with MIT License 6 votes vote down vote up
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) 
Example #2
Source File: test_simple_decompression.py    From brotlipy with MIT License 6 votes vote down vote up
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 
Example #3
Source File: response.py    From Cloudmare with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #4
Source File: response.py    From luci-py with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #5
Source File: response.py    From CudaText with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #6
Source File: response.py    From CudaText with Mozilla Public License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #7
Source File: test_simple_decompression.py    From brotlipy with MIT License 5 votes vote down vote up
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 
Example #8
Source File: test_simple_decompression.py    From brotlipy with MIT License 5 votes vote down vote up
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') 
Example #9
Source File: test_simple_compression.py    From brotlipy with MIT License 5 votes vote down vote up
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 
Example #10
Source File: response.py    From rules_pip with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #11
Source File: response.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #12
Source File: response.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #13
Source File: response.py    From CogAlg with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #14
Source File: response.py    From quickstart-redhat-openshift with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #15
Source File: response.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #16
Source File: response.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #17
Source File: response.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #18
Source File: response.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #19
Source File: response.py    From addon with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #20
Source File: response.py    From bash-lambda-layer with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #21
Source File: response.py    From cronyo with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #22
Source File: response.py    From scylla with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #23
Source File: bufferedreaders.py    From warcio with Apache License 2.0 5 votes vote down vote up
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


#================================================================= 
Example #24
Source File: bufferedreaders.py    From warcio with Apache License 2.0 5 votes vote down vote up
def gzip_decompressor():
    """
    Decompressor which can handle decompress gzip stream
    """
    return zlib.decompressobj(16 + zlib.MAX_WBITS) 
Example #25
Source File: response.py    From pipenv with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #26
Source File: response.py    From pipenv with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #27
Source File: response.py    From pex with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #28
Source File: response.py    From satori with Apache License 2.0 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #29
Source File: response.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor() 
Example #30
Source File: response.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def __init__(self):
            self._obj = brotli.Decompressor()