diff options
-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 |