summaryrefslogtreecommitdiffstats
path: root/tools/skeleton.py
diff options
context:
space:
mode:
authorBoris Nagaev <bnagaev@gmail.com>2016-07-12 08:37:22 (GMT)
committerBoris Nagaev <bnagaev@gmail.com>2016-07-12 08:37:22 (GMT)
commit38a5c97d0b6cee5fb4c658ef4ec1843ec9bb2d0a (patch)
tree1be6f0d51314ef60665a67a79edf36588c496988 /tools/skeleton.py
parentf1581d20bf6604171adb20188221f526846b9cc1 (diff)
downloadmxe-38a5c97d0b6cee5fb4c658ef4ec1843ec9bb2d0a.zip
mxe-38a5c97d0b6cee5fb4c658ef4ec1843ec9bb2d0a.tar.gz
mxe-38a5c97d0b6cee5fb4c658ef4ec1843ec9bb2d0a.tar.bz2
skeleton: don't truncate index.html on write error
Write new version to a temporary file and rename it to index.html.
Diffstat (limited to 'tools/skeleton.py')
-rwxr-xr-xtools/skeleton.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/skeleton.py b/tools/skeleton.py
index 548bd40..e7857a3 100755
--- a/tools/skeleton.py
+++ b/tools/skeleton.py
@@ -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,