From 4d13cdfb4644597b73ec2b66b9d23743f07922e7 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 14 May 2024 23:05:53 +0200 Subject: [PATCH] errors: use color wrapper This allows the program to work without termcolor installed --- compiler/errors.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/errors.py b/compiler/errors.py index 099340d..71d3d0f 100644 --- a/compiler/errors.py +++ b/compiler/errors.py @@ -5,16 +5,14 @@ import inspect import sys from typing import TextIO -from termcolor import termcolor - -from . import source, lexer +from . import source, lexer, color from .logger import rootLogger, LogLevel from .source import TextIOWithMemory class LevelType: - def __init__(self, name: str, color: termcolor.Color = None): + def __init__(self, name: str, color: color.Color = None): """ :param name: @@ -27,7 +25,7 @@ class LevelType: return self.show_with_suffix() 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):