summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2016-01-18 18:12:32 +0100
committerChristian Franke <nobody@nowhere.ws>2016-01-18 18:12:32 +0100
commit6ffcc8059b9d4466343c8c4e26b80f06738db437 (patch)
tree0a07a8b490198237297877f5282d687277315f7d
parent19d290ea5ee6487dfcd5a5ecc59b38755e9bad98 (diff)
Atomically replaces pages on rebuild
-rwxr-xr-xscripts/template.py7
1 files changed, 4 insertions, 3 deletions
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