skeleton: don't truncate index.html on write error

Write new version to a temporary file and rename it to index.html.
This commit is contained in:
Boris Nagaev 2016-07-12 11:37:22 +03:00
parent f1581d20bf
commit 38a5c97d0b
1 changed files with 3 additions and 1 deletions

View File

@ -170,8 +170,10 @@ def update_index_html(name, description, website):
packages_html += '\n'
# build and write HTML
index_html = prefix + sep1 + packages_html + sep2 + suffix
with open('index.html', 'wt') as f:
(_, tmp_index_html) = tempfile.mkstemp()
with open(tmp_index_html, 'wt') as f:
f.write(index_html)
os.rename(tmp_index_html, 'index.html')
def make_skeleton(
name,