This commit is contained in:
MinchinWeb 2017-03-28 20:20:46 +00:00 committed by GitHub
commit 184d67256f

View file

@ -126,13 +126,14 @@ def load_and_fix_json(json_path):
sys.exit(1)
def get_text_from_editor(config, template=""):
_, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
with codecs.open(tmpfile, 'w', "utf-8") as f:
if template:
f.write(template)
subprocess.call(config['editor'].split() + [tmpfile])
with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read()
os.close(filehandle);
os.remove(tmpfile)
if not raw:
prompt('[Nothing saved to file]')