xref: /petsc/lib/petsc/bin/maint/petsclinter/petsclinter/util/_color.py (revision 4c7cc9c8e01791debde927bc0816c9a347055c8f)
1#!/usr/bin/env python3
2"""
3# Created: Wed Jul  5 15:40:46 2023 (-0400)
4# @author: Jacob Faibussowitsch
5"""
6class Color:
7  try:
8    import colorama # type: ignore[import]
9
10    __COLOR_BRIGHT_RED__: str    = colorama.Fore.RED + colorama.Style.BRIGHT
11    __COLOR_BRIGHT_YELLOW__: str = colorama.Fore.YELLOW + colorama.Style.BRIGHT
12    __COLOR_RESET__: str         = colorama.Style.RESET_ALL
13  except ImportError:
14    __COLOR_BRIGHT_RED__    = ''
15    __COLOR_BRIGHT_YELLOW__ = ''
16    __COLOR_RESET__         = ''
17
18  @classmethod
19  def bright_red(cls) -> str:
20    r"""Return the ASCII code for bright red
21
22    Returns
23    -------
24    ret :
25      the ASCII code for bright red for the current terminal type
26    """
27    return cls.__COLOR_BRIGHT_RED__
28
29  @classmethod
30  def bright_yellow(cls) -> str:
31    r"""Return the ASCII code for bright yellow
32
33    Returns
34    -------
35    ret :
36      the ASCII code for bright yellow
37    """
38    return cls.__COLOR_BRIGHT_YELLOW__
39
40  @classmethod
41  def reset(cls) -> str:
42    r"""Return the ASCII code for resetting color
43
44    Returns
45    -------
46    ret :
47      the ASCII code to reset all color characteristics
48    """
49    return cls.__COLOR_RESET__
50