mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 19:48:31 +02:00
Name file handle if we're going to us it
This commit is contained in:
parent
0438ff33cc
commit
4527866e2d
1 changed files with 2 additions and 2 deletions
|
@ -126,14 +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(_);
|
||||
os.close(filehandle);
|
||||
os.remove(tmpfile)
|
||||
if not raw:
|
||||
prompt('[Nothing saved to file]')
|
||||
|
|
Loading…
Add table
Reference in a new issue