diff options
author | outa <outa@users.noreply.github.com> | 2022-10-08 22:48:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-08 13:48:29 -0700 |
commit | d7242d81a463b790f6650a18fce2b8047d776fbc (patch) | |
tree | a3a7ef7d78e0c44bafceb49b14f4460af4ae2c38 /jrnl | |
parent | a925c81ba8acad9bdc03a86d24af521f66b48e74 (diff) |
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
Diffstat (limited to 'jrnl')
-rw-r--r-- | jrnl/plugins/text_exporter.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 931305ef..4451cfef 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -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): |