Skip to content
Snippets Groups Projects
Commit 85d36c2c authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

write the temporary file next to the one we are about to overwrite

parent d00bf0f3
No related branches found
No related tags found
No related merge requests found
......@@ -39,5 +39,8 @@
def write_data(path, data):
"""write description data at <path>"""
with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
directory = os.path.dirname(path)
basename = os.path.basename(path)
tmp_path = os.path.join(directory, f".{basename}.tmp")
with open(tmp_path, "w") as f:
toml.dump(data, f)
......@@ -43,5 +46,5 @@
toml.dump(data, f)
os.replace(f.name, path)
os.replace(tmp_path, path)
def show(data, indent=''):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment