summaryrefslogtreecommitdiffstatshomepage
path: root/py/makeqstrdefs.py
diff options
context:
space:
mode:
authorTrent Piepho <tpiepho@gmail.com>2023-12-14 22:51:45 -0800
committerTrent Piepho <tpiepho@gmail.com>2023-12-14 22:55:08 -0800
commit0e706a62b168b7c2818f99d8785fe4dd31af9169 (patch)
tree8fb631cc47805255a688c3d9b14bfaaeb18b6b52 /py/makeqstrdefs.py
parent2e101a8e44b7f1bff75cc06a0597c572a8d8d152 (diff)
downloadmicropython-0e706a62b168b7c2818f99d8785fe4dd31af9169.tar.gz
micropython-0e706a62b168b7c2818f99d8785fe4dd31af9169.zip
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>
Diffstat (limited to 'py/makeqstrdefs.py')
-rw-r--r--py/makeqstrdefs.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py
index bdc432d7dd..8e930ef506 100644
--- a/py/makeqstrdefs.py
+++ b/py/makeqstrdefs.py
@@ -138,15 +138,12 @@ def cat_together():
hasher = hashlib.md5()
all_lines = []
- outf = open(args.output_dir + "/out", "wb")
for fname in glob.glob(args.output_dir + "/*." + args.mode):
with open(fname, "rb") as f:
lines = f.readlines()
all_lines += lines
all_lines.sort()
all_lines = b"\n".join(all_lines)
- outf.write(all_lines)
- outf.close()
hasher.update(all_lines)
new_hash = hasher.hexdigest()
# print(new_hash)
@@ -165,12 +162,9 @@ def cat_together():
mode_full = "Root pointer registrations"
if old_hash != new_hash or not os.path.exists(args.output_file):
print(mode_full, "updated")
- try:
- # rename below might fail if file exists
- os.remove(args.output_file)
- except:
- pass
- os.rename(args.output_dir + "/out", args.output_file)
+
+ with open(args.output_file, "wb") as outf:
+ outf.write(all_lines)
with open(args.output_file + ".hash", "w") as f:
f.write(new_hash)
else: