errors: use color wrapper

This allows the program to work without termcolor installed
This commit is contained in:
Antoine Viallon 2024-05-14 23:05:53 +02:00
parent df65952cfc
commit 4d13cdfb46
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -5,16 +5,14 @@ import inspect
import sys import sys
from typing import TextIO from typing import TextIO
from termcolor import termcolor from . import source, lexer, color
from . import source, lexer
from .logger import rootLogger, LogLevel from .logger import rootLogger, LogLevel
from .source import TextIOWithMemory from .source import TextIOWithMemory
class LevelType: class LevelType:
def __init__(self, name: str, color: termcolor.Color = None): def __init__(self, name: str, color: color.Color = None):
""" """
:param name: :param name:
@ -27,7 +25,7 @@ class LevelType:
return self.show_with_suffix() return self.show_with_suffix()
def show_with_suffix(self, suffix=":") -> str: def show_with_suffix(self, suffix=":") -> str:
return termcolor.colored(f"{self.name}{suffix}", color=self.color, attrs=["bold"]) return color.colored(f"{self.name}{suffix}", color=self.color, attrs=["bold"])
class Levels(enum.Enum): class Levels(enum.Enum):