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

View file

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