cornsnake.util_color
Defines color constants and a function for colorizing text output for terminal.
1""" 2Defines color constants and a function for colorizing text output for terminal. 3 4[Documentation](http://docs.mrseanryan.cornsnake.s3-website-eu-west-1.amazonaws.com/cornsnake/util_color.html) 5""" 6 7from . import config 8 9 10class bcolors: 11 HEADER = "\033[95m" 12 DARK_BLUE = "\033[34m" 13 MAGENTA = "\033[95m" 14 DARK_MAGENTA = "\033[35m" 15 DARK_CYAN = "\033[36m" 16 OKBLUE = "\033[94m" 17 OKCYAN = "\033[96m" 18 OKGREEN = "\033[92m" 19 WARNING = "\033[93m" 20 FAIL = "\033[91m" 21 ENDC = "\033[0m" 22 BOLD = "\033[1m" 23 UNDERLINE = "\033[4m" 24 25 26def colorize(text, color): 27 """ 28 Function to colorize text output for terminal. 29 30 Args: 31 text (str): The text to be colorized. 32 color (str): The color to apply to the text. 33 34 Returns: 35 str: The colorized text. 36 """ 37 start_color = color if config.IS_COLOR_ENABLED else "" 38 end_color = bcolors.ENDC if config.IS_COLOR_ENABLED else "" 39 colorized = f"{start_color}{text}{end_color}" 40 return colorized 41 42 43# Theming 44CONFIG_COLOR = bcolors.DARK_MAGENTA 45IMPORTANT = bcolors.WARNING 46QUESTION_COLOR = bcolors.DARK_CYAN 47RESULT_COLOR = bcolors.OKGREEN + bcolors.BOLD 48SECTION_COLOR = bcolors.OKBLUE + bcolors.BOLD 49TEST_SECTION_COLOR = bcolors.WARNING + bcolors.BOLD 50ERROR_COLOR = bcolors.FAIL + bcolors.BOLD 51WARNING_COLOR = bcolors.WARNING + bcolors.BOLD 52END_COLORS = bcolors.ENDC
class
bcolors:
11class bcolors: 12 HEADER = "\033[95m" 13 DARK_BLUE = "\033[34m" 14 MAGENTA = "\033[95m" 15 DARK_MAGENTA = "\033[35m" 16 DARK_CYAN = "\033[36m" 17 OKBLUE = "\033[94m" 18 OKCYAN = "\033[96m" 19 OKGREEN = "\033[92m" 20 WARNING = "\033[93m" 21 FAIL = "\033[91m" 22 ENDC = "\033[0m" 23 BOLD = "\033[1m" 24 UNDERLINE = "\033[4m"
def
colorize(text, color):
27def colorize(text, color): 28 """ 29 Function to colorize text output for terminal. 30 31 Args: 32 text (str): The text to be colorized. 33 color (str): The color to apply to the text. 34 35 Returns: 36 str: The colorized text. 37 """ 38 start_color = color if config.IS_COLOR_ENABLED else "" 39 end_color = bcolors.ENDC if config.IS_COLOR_ENABLED else "" 40 colorized = f"{start_color}{text}{end_color}" 41 return colorized
Function to colorize text output for terminal.
Args: text (str): The text to be colorized. color (str): The color to apply to the text.
Returns: str: The colorized text.
CONFIG_COLOR =
'\x1b[35m'
IMPORTANT =
'\x1b[93m'
QUESTION_COLOR =
'\x1b[36m'
RESULT_COLOR =
'\x1b[92m\x1b[1m'
SECTION_COLOR =
'\x1b[94m\x1b[1m'
TEST_SECTION_COLOR =
'\x1b[93m\x1b[1m'
ERROR_COLOR =
'\x1b[91m\x1b[1m'
WARNING_COLOR =
'\x1b[93m\x1b[1m'
END_COLORS =
'\x1b[0m'