File size: 549 Bytes
246d201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from enum import Enum

from termcolor import colored


class TermColor(Enum):
    """Terminal color codes."""

    WARNING = 'yellow'
    SUCCESS = 'green'
    ERROR = 'red'
    INFO = 'blue'


def colorize(text: str, color: TermColor = TermColor.WARNING) -> str:
    """Colorize text with specified color.



    Args:

        text (str): Text to be colored

        color (TermColor, optional): Color to use. Defaults to TermColor.WARNING



    Returns:

        str: Colored text

    """
    return colored(text, color.value)