Have temporary filename suffix be -{template_filename} or .jrnl

This commit is contained in:
karimpwnz 2021-01-02 20:55:54 +02:00
parent 4bbd2fe53b
commit 7405221a8a

View file

@ -5,14 +5,18 @@ import subprocess
import sys
import tempfile
import textwrap
from pathlib import Path
from .color import ERROR_COLOR
from .color import RESET_COLOR
from .os_compat import on_windows
def get_text_from_editor(config, template=""):
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=".txt")
def get_text_from_editor(config, template="", suffix=".jrnl"):
if config["template"]:
template_filename = Path(config["template"]).name
suffix = "-" + template_filename
filehandle, tmpfile = tempfile.mkstemp(prefix="jrnl", text=True, suffix=suffix)
os.close(filehandle)
with open(tmpfile, "w", encoding="utf-8") as f: