"""A script that replaces an old file with a new one, only if the contentsactually changed. If not, the new file is simply deleted.This avoids wholesale rebuilds when a code (re)generation phase does notactually change the in-tree generated code."""import osimport sysdef main(old_path, new_path):with open(old_path, 'rb') as f:old_contents = f.read()with open(new_path, 'rb') as f:new_contents = f.read()if old_contents != new_contents:os.replace(new_path, old_path)else:os.unlink(new_path)if __name__ == '__main__':if len(sys.argv) != 3:print("Usage: %s <path to be updated> <path with new contents>" % (sys.argv[0],))sys.exit(1)main(sys.argv[1], sys.argv[2])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。