Skip to content

color

color

blue(var, loud=True, logger=None)

Print the given variable in blue color using colorama and return the colored string.

Parameters:

Name Type Description Default
var Any

The variable to be printed in red color.

required
loud bool

If True, print the colored output to the console. Defaults to True.

True
logger Optional[Logger]

The logger to be used for logging. If provided, the colored output will be logged using this logger. Defaults to None.

None

Returns:

Name Type Description
str str

The input variable formatted as a red-colored string.

Source code in alana/color.py
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def blue(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """
    Print the given variable in blue color using colorama and return the colored string.

    Args:
        var (Any): The variable to be printed in red color.
        loud (bool, optional): If True, print the colored output to the console. Defaults to True.
        logger (Optional[logging.Logger], optional): The logger to be used for logging.
            If provided, the colored output will be logged using this logger. Defaults to None.

    Returns:
        str: The input variable formatted as a red-colored string.
    """
    output = f"{Fore.BLUE} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output

cyan(var, loud=True, logger=None)

Print var in cyan, like alana.blue

Source code in alana/color.py
59
60
61
62
63
def cyan(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """Print var in cyan, like `alana.blue`"""
    output = f"{Fore.CYAN} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output

green(var, loud=True, logger=None)

Print var in green, like alana.blue

Source code in alana/color.py
30
31
32
33
34
def green(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """Print var in green, like `alana.blue`"""
    output = f"{Fore.GREEN} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output

log(loud, output, logger=None)

Log the output based on the provided parameters.

Parameters:

Name Type Description Default
loud bool

If True, print the output to the console.

required
output str

The string to be logged.

required
logger Optional[Logger]

The logger to be used for logging. If provided, the output will be logged using this logger. Defaults to None.

None
Source code in alana/color.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def log(loud: bool, output: str, logger: Optional[logging.Logger] = None) -> None:
    """
    Log the output based on the provided parameters.

    Args:
        loud (bool): If True, print the output to the console.
        output (str): The string to be logged.
        logger (Optional[logging.Logger], optional): The logger to be used for logging.
            If provided, the output will be logged using this logger. Defaults to None.
    """
    if loud:
        print(output)
    if logger:
        logger.info(output)

pink(var, loud=True, logger=None)

Print var in pink, like alana.blue

Source code in alana/color.py
65
66
67
68
69
def pink(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """Print var in pink, like `alana.blue`"""
    output = f"{Fore.MAGENTA} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output

red(var, loud=True, logger=None)

Print var in red, like alana.blue

Source code in alana/color.py
24
25
26
27
28
def red(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """Print var in red, like `alana.blue`"""
    output = f"{Fore.RED} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output

yellow(var, loud=True, logger=None)

Print var in yellow, like alana.blue

Source code in alana/color.py
53
54
55
56
57
def yellow(var: Any, loud: bool = True, logger: Optional[logging.Logger] = None) -> str:
    """Print var in yellow, like `alana.blue`"""
    output = f"{Fore.YELLOW} {var} {Style.RESET_ALL}"
    log(loud, output, logger)
    return output