filetype.py icon indicating copy to clipboard operation
filetype.py copied to clipboard

Add support for Brotli compression

Open Faisal-Manzer opened this issue 5 years ago • 1 comments

Brotli is now a widely supported compression type. We should include that too.

Faisal-Manzer avatar Jan 12 '20 17:01 Faisal-Manzer

It would be nice to have this also in this library, however it looks like brotli for now has no fixed file signature, although this has been proposed.

In the meantime you can check if something is brotli compressed by try to decompressing it using brotlipy.

For example:

import brotli

a = brotli.compress(b'test')  # brotli compressed 
b = b'test'  # normal 

def x(y):
    try:
        return bool(brotli.decompress(y))
    except brotli.brotli.Error:
        return False

>>> x(a)
True
>>> x(b)
False

fili avatar Mar 26 '20 08:03 fili