diff options
author | Christian Franke <nobody@nowhere.ws> | 2016-01-18 18:12:32 +0100 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2016-01-18 18:12:32 +0100 |
commit | 6ffcc8059b9d4466343c8c4e26b80f06738db437 (patch) | |
tree | 0a07a8b490198237297877f5282d687277315f7d /scripts | |
parent | 19d290ea5ee6487dfcd5a5ecc59b38755e9bad98 (diff) |
Atomically replaces pages on rebuild
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/template.py | 7 |
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 |