def METHOD_NAME(code: str) -> bool:
    if os.access(nn_cache_file_path.as_posix(), os.W_OK) or (
        not nn_cache_file_path.exists() and os.access(nn_cache_file_path.parent.as_posix(), os.W_OK)
    ):
        with nn_cache_file_path.open('w') as fp:
            fp.write(code)
        return True
    else:
        # no permission
        return False