Skip to content

Commit

Permalink
feat(fetcher): Override used sty background colors at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiWo committed Oct 12, 2023
1 parent 003cff3 commit da7c162
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions duties/fetcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

import sys
from logging import config as logging_config
from os import path
from os import path, system
from typing import Any

from cli.arguments import ARGUMENTS
from colorama import init
from constants.program import USED_STY_BACKGROUND_COLOR_NAMES
from sty import RgbBg, Style, bg # type: ignore[import]
from yaml import safe_load


def __initialize() -> None:
"""Initializes logger and colorama"""
system("")
__initialize_logging(ARGUMENTS.log)
__initialize_colorama()
__set_colors()


def __initialize_logging(log_level: str) -> None:
Expand Down Expand Up @@ -49,9 +51,26 @@ def __get_logging_configuration_path() -> str:
return logging_configuration_path


def __initialize_colorama() -> None:
"""Initializes coloroma so that colorful logging works independent from OS"""
init()
def __set_colors() -> None:
"""Overrides used color attributes of sty package"""
log_color_arguments = [
argument
# pylint: disable-next=protected-access
for argument in ARGUMENTS._get_kwargs()
if argument[0].startswith("log_color")
]
for index, color_name in enumerate(USED_STY_BACKGROUND_COLOR_NAMES):
setattr(
bg,
color_name,
Style(
RgbBg(
log_color_arguments[index][1][0],
log_color_arguments[index][1][1],
log_color_arguments[index][1][2],
)
),
)


__initialize()

0 comments on commit da7c162

Please sign in to comment.