filetype.py
filetype.py copied to clipboard
Add support for Brotli compression
Brotli is now a widely supported compression type. We should include that too.
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