change print statement over to new print_msg function

This commit is contained in:
Jonathan Wren 2022-04-16 16:17:15 -07:00
parent 0fc8bcfbc2
commit 42373760ff
2 changed files with 18 additions and 3 deletions

View file

@ -12,6 +12,11 @@ from . import Entry
from . import time from . import time
from .prompt import yesno from .prompt import yesno
from jrnl.output import print_msg
from jrnl.messages import Message
from jrnl.messages import MsgText
from jrnl.messages import MsgType
class Tag: class Tag:
def __init__(self, name, count=0): def __init__(self, name, count=0):
@ -408,9 +413,14 @@ def open_journal(journal_name, config, legacy=False):
if os.path.isdir(config["journal"]): if os.path.isdir(config["journal"]):
if config["encrypt"]: if config["encrypt"]:
print( print_msg(
"Warning: This journal's config has 'encrypt' set to true, but this type of journal can't be encrypted.", Message(
file=sys.stderr, MsgText.ConfigEncryptedForUnencryptableJournalType,
MsgType.WARNING,
{
"journal_name": journal_name,
},
)
) )
if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir( if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir(

View file

@ -60,6 +60,11 @@ class MsgText(Enum):
this journal to the new journal, then encrypt the new journal. this journal to the new journal, then encrypt the new journal.
""" """
ConfigEncryptedForUnencryptableJournalType = """
The config for journal "{journal_name}" has 'encrypt' set to true, but this type
of journal can't be encrypted. Please fix your config file.
"""
KeyboardInterruptMsg = "Aborted by user" KeyboardInterruptMsg = "Aborted by user"
CantReadTemplate = """ CantReadTemplate = """