You could use a standard mimetype module for determine content type and encoding by filename, eg:
In [1]: import mimetypes
In [2]: mimetypes.guess_type('hello.txt.gz')
Out[2]: ('text/plain', 'gzip')
In [3]: mimetypes.guess_type('hello.pdf.gz')
Out[3]: ('application/pdf', 'gzip')
In [4]: mimetypes.guess_type('hello.pdf')
Out[4]: ('application/pdf', None)