mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 05:56:14 +02:00
Don't create empty file when attempting a YAML export to a non-existing folder (#1600)
* Call `export_journal` before opening file handle * Use correct exporter class * Fix unit test
This commit is contained in:
parent
a925c81ba8
commit
d7242d81a4
2 changed files with 29 additions and 10 deletions
|
@ -31,18 +31,19 @@ class TextExporter:
|
|||
@classmethod
|
||||
def write_file(cls, journal, path):
|
||||
"""Exports a journal into a single file."""
|
||||
export_str = cls.export_journal(journal)
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(cls.export_journal(journal))
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.JournalExportedTo,
|
||||
MsgStyle.NORMAL,
|
||||
{
|
||||
"path": path,
|
||||
},
|
||||
)
|
||||
f.write(export_str)
|
||||
print_msg(
|
||||
Message(
|
||||
MsgText.JournalExportedTo,
|
||||
MsgStyle.NORMAL,
|
||||
{
|
||||
"path": path,
|
||||
},
|
||||
)
|
||||
return ""
|
||||
)
|
||||
return ""
|
||||
|
||||
@classmethod
|
||||
def make_filename(cls, entry):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue