Touch tmpfiles before opening

This commit is contained in:
Manuel Ebert 2014-01-02 07:48:57 +01:00
parent 860d74bc0e
commit 77b669aedf
4 changed files with 20 additions and 8 deletions

View file

@ -7,7 +7,7 @@ jrnl is a simple journal application for your command line.
"""
__title__ = 'jrnl'
__version__ = '1.7.2'
__version__ = '1.7.3'
__author__ = 'Manuel Ebert'
__license__ = 'MIT License'
__copyright__ = 'Copyright 2013 Manuel Ebert'

View file

@ -129,14 +129,13 @@ def get_text_from_editor(config, template=""):
if template:
with codecs.open(tmpfile, 'w', "utf-8") as f:
f.write(template)
with open(tmpfile, 'w'):
pass
subprocess.call(config['editor'].split() + [tmpfile])
if os.path.exists(tmpfile):
with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read()
os.remove(tmpfile)
else:
with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read()
os.remove(tmpfile)
if not raw:
prompt('[Nothing saved to file]')
raw = ''
return raw