def file_type(path):
    """Identifies what the type of file is."""
    signature = {'\x1f\x8b\x08': 'gz', 'BZh': 'bz2', 'PK\x03\x04': 'zip'}
    with open(path) as f:
        for sig, f_type in signature.items():
            if f.read(4).startswith(sig):
                return f_type
