update yaml format to use new message function

This commit is contained in:
Jonathan Wren 2022-05-01 03:37:35 -07:00
parent c16aa42d6c
commit 7ded211ff8
2 changed files with 10 additions and 9 deletions

View file

@ -150,6 +150,10 @@ class MsgText(Enum):
Headings increased past H6 on export - {date} {title} Headings increased past H6 on export - {date} {title}
""" """
YamlMustBeDirectory = """
YAML export must be to a directory, not a single file
"""
# --- Import --- # # --- Import --- #
ImportSummary = """ ImportSummary = """
{count} imported to {journal_name} journal {count} imported to {journal_name} journal

View file

@ -6,12 +6,13 @@ import os
import re import re
import sys import sys
from jrnl.color import ERROR_COLOR
from jrnl.color import RESET_COLOR
from jrnl.color import WARNING_COLOR
from .text_exporter import TextExporter from .text_exporter import TextExporter
from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgText
from jrnl.messages import MsgType
class YAMLExporter(TextExporter): class YAMLExporter(TextExporter):
"""This Exporter can convert entries and journals into Markdown formatted text with YAML front matter.""" """This Exporter can convert entries and journals into Markdown formatted text with YAML front matter."""
@ -129,8 +130,4 @@ class YAMLExporter(TextExporter):
@classmethod @classmethod
def export_journal(cls, journal): def export_journal(cls, journal):
"""Returns an error, as YAML export requires a directory as a target.""" """Returns an error, as YAML export requires a directory as a target."""
raise RuntimeError( raise JrnlException(Message(MsgText.YamlMustBeDirectory, MsgType.ERROR))
"{}ERROR{}: YAML export must be to individual files. Please specify a directory to export to.".format(
ERROR_COLOR, RESET_COLOR
)
)