Make editing work with templates

This commit is contained in:
Manuel Ebert 2014-01-03 15:52:59 +01:00
parent 3f9d9bf84f
commit 03bce74262

View file

@ -128,11 +128,9 @@ def load_and_fix_json(json_path):
def get_text_from_editor(config, template=""): def get_text_from_editor(config, template=""):
tmpfile = os.path.join(tempfile.gettempdir(), "jrnl") tmpfile = os.path.join(tempfile.gettempdir(), "jrnl")
if template:
with codecs.open(tmpfile, 'w', "utf-8") as f: with codecs.open(tmpfile, 'w', "utf-8") as f:
if template:
f.write(template) f.write(template)
with open(tmpfile, 'w'):
pass
subprocess.call(config['editor'].split() + [tmpfile]) subprocess.call(config['editor'].split() + [tmpfile])
with codecs.open(tmpfile, "r", "utf-8") as f: with codecs.open(tmpfile, "r", "utf-8") as f:
raw = f.read() raw = f.read()