def METHOD_NAME(path):
    magic_map = {
        b"\x1f\x8b\x08": TARArchiver,
        b"\x42\x5a\x68": TARArchiver,
        b"\x50\x4b\x03\x04": ZIPArchiver,
    }
    magic_len = max(len(k) for k in magic_map)
    with open(path, "rb") as fp:
        data = fp.read(magic_len)
        for magic, archiver in magic_map.items():
            if data.startswith(magic):
                return archiver(path)
    raise PackageException("Unknown archive type '%s'" % path)