Skip to content

Commit b57b40d

Browse files
committed
Write to the file
1 parent d9b80eb commit b57b40d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def main():
196196

197197
# Get header content before and after the generated block.
198198
path_header = "PhysicsConstants.h"
199+
print(f"File {path_header} will be updated.")
199200
try:
200201
with open(path_header, encoding="utf-8") as file:
201202
content_old = file.readlines()
@@ -252,7 +253,15 @@ def main():
252253
*lines_header_after,
253254
)
254255
)
255-
print(content_new)
256+
# print(content_new)
257+
258+
try:
259+
with open(path_header, "w", encoding="utf-8") as file:
260+
file.write(content_new)
261+
print(f"File {path_header} has been overwritten.")
262+
except OSError:
263+
print(f'Failed to write to file "{path_header}".')
264+
sys.exit(1)
256265

257266

258267
if __name__ == "__main__":

0 commit comments

Comments
 (0)