From 6ffcc8059b9d4466343c8c4e26b80f06738db437 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Mon, 18 Jan 2016 18:12:32 +0100 Subject: Atomically replaces pages on rebuild --- scripts/template.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/template.py b/scripts/template.py index 91cfdd3..1580463 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -59,9 +59,10 @@ class Page: def render_and_save(self): #write it to the outputfile - outputfile = open(os.path.join(targetdir, self.name + '.html'), "w") - outputfile.write(self.html) - outputfile.close() + target = os.path.join(targetdir, self.name + '.html') + with open(target + '.new', 'w') as outputfile: + outputfile.write(self.html) + os.rename(target + '.new', target) configfile = "template.conf" verbose = False -- cgit v1.2.1