kopia lustrzana https://github.com/micropython/micropython
py/makeqstrdefs.py: Stop generating temporary intermediate file.
In "cat" mode, output was written to a file named "out", then moved to the location of the real output file. There was no reason for this. While makeqstrdefs.py does make an effort to not update the timestamp on an existing output file that has not changed, the intermediate "out" file isn't part of the that process. Signed-off-by: Trent Piepho <tpiepho@gmail.com>pull/13208/head
rodzic
2e101a8e44
commit
0e706a62b1
|
@ -138,15 +138,12 @@ def cat_together():
|
||||||
|
|
||||||
hasher = hashlib.md5()
|
hasher = hashlib.md5()
|
||||||
all_lines = []
|
all_lines = []
|
||||||
outf = open(args.output_dir + "/out", "wb")
|
|
||||||
for fname in glob.glob(args.output_dir + "/*." + args.mode):
|
for fname in glob.glob(args.output_dir + "/*." + args.mode):
|
||||||
with open(fname, "rb") as f:
|
with open(fname, "rb") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
all_lines += lines
|
all_lines += lines
|
||||||
all_lines.sort()
|
all_lines.sort()
|
||||||
all_lines = b"\n".join(all_lines)
|
all_lines = b"\n".join(all_lines)
|
||||||
outf.write(all_lines)
|
|
||||||
outf.close()
|
|
||||||
hasher.update(all_lines)
|
hasher.update(all_lines)
|
||||||
new_hash = hasher.hexdigest()
|
new_hash = hasher.hexdigest()
|
||||||
# print(new_hash)
|
# print(new_hash)
|
||||||
|
@ -165,12 +162,9 @@ def cat_together():
|
||||||
mode_full = "Root pointer registrations"
|
mode_full = "Root pointer registrations"
|
||||||
if old_hash != new_hash or not os.path.exists(args.output_file):
|
if old_hash != new_hash or not os.path.exists(args.output_file):
|
||||||
print(mode_full, "updated")
|
print(mode_full, "updated")
|
||||||
try:
|
|
||||||
# rename below might fail if file exists
|
with open(args.output_file, "wb") as outf:
|
||||||
os.remove(args.output_file)
|
outf.write(all_lines)
|
||||||
except:
|
|
||||||
pass
|
|
||||||
os.rename(args.output_dir + "/out", args.output_file)
|
|
||||||
with open(args.output_file + ".hash", "w") as f:
|
with open(args.output_file + ".hash", "w") as f:
|
||||||
f.write(new_hash)
|
f.write(new_hash)
|
||||||
else:
|
else:
|
||||||
|
|
Ładowanie…
Reference in New Issue