update importer to use new message function

This commit is contained in:
Jonathan Wren 2022-05-01 03:24:37 -07:00
parent 42373760ff
commit c16aa42d6c
2 changed files with 13 additions and 4 deletions

View file

@ -150,6 +150,11 @@ class MsgText(Enum):
Headings increased past H6 on export - {date} {title}
"""
# --- Import --- #
ImportSummary = """
{count} imported to {journal_name} journal
"""
class Message(NamedTuple):
text: MsgText

View file

@ -8,6 +8,7 @@ from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgText
from jrnl.messages import MsgType
from jrnl.output import print_msg
class JRNLImporter:
@ -34,8 +35,11 @@ class JRNLImporter:
journal.import_(other_journal_txt)
new_cnt = len(journal.entries)
print(
"[{} imported to {} journal]".format(new_cnt - old_cnt, journal.name),
file=sys.stderr,
)
journal.write()
print_msg(
Message(
MsgText.ImportSummary,
MsgType.NORMAL,
{"count": new_cnt - old_cnt, "journal_name": journal.name},
)
)