update config module to use new message function

This commit is contained in:
Jonathan Wren 2022-05-01 04:03:49 -07:00
parent 2df7419ac1
commit 8088083737
2 changed files with 14 additions and 9 deletions

View file

@ -1,20 +1,18 @@
import logging
import os
import sys
import colorama
from ruamel.yaml import YAML
import xdg.BaseDirectory
from . import __version__
from jrnl.output import list_journals
from jrnl.output import print_msg
from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgText
from jrnl.messages import MsgType
from .color import ERROR_COLOR
from .color import RESET_COLOR
from .output import list_journals
# Constants
DEFAULT_CONFIG_NAME = "jrnl.yaml"
@ -146,11 +144,15 @@ def verify_config_colors(config):
if upper_color == "NONE":
continue
if not getattr(colorama.Fore, upper_color, None):
print(
"[{2}ERROR{3}: {0} set to invalid color: {1}]".format(
key, color, ERROR_COLOR, RESET_COLOR
),
file=sys.stderr,
print_msg(
Message(
MsgText.InvalidColor,
MsgType.NORMAL,
{
"key": key,
"color": color,
},
)
)
all_valid_colors = False
return all_valid_colors

View file

@ -167,6 +167,9 @@ class MsgText(Enum):
{count} imported to {journal_name} journal
"""
# --- Color --- #
InvalidColor = "{key} set to invalid color: {color}"
class Message(NamedTuple):
text: MsgText