Colors

ANSI color and style utilities.

class Color(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
BLACK = '\x1b[30m'
BLUE = '\x1b[34m'
BRIGHT_BLACK = '\x1b[90m'
BRIGHT_BLUE = '\x1b[94m'
BRIGHT_CYAN = '\x1b[96m'
BRIGHT_GREEN = '\x1b[92m'
BRIGHT_MAGENTA = '\x1b[95m'
BRIGHT_RED = '\x1b[91m'
BRIGHT_WHITE = '\x1b[97m'
BRIGHT_YELLOW = '\x1b[93m'
CYAN = '\x1b[36m'
GREEN = '\x1b[32m'
MAGENTA = '\x1b[35m'
NORMAL = '\x1b[0m'
RED = '\x1b[31m'
WHITE = '\x1b[37m'
YELLOW = '\x1b[33m'
classmethod from_string(color)[source]

Create a Color enum value from a named string.

Return type:

Color

Parameters:

color (str) – The name of the color.

Returns:

The Color enum value.

Return type:

Color

class Style(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
BOLD = '\x1b[1m'
ITALIC = '\x1b[3m'
NORMAL = '\x1b[0m'
STRIKETHROUGH = '\x1b[9m'
UNDERLINE = '\x1b[4m'
classmethod from_string(style)[source]

Create a Style enum value from a named string.

Return type:

Style

colorize(text, color)[source]

Colorize text with the specified color.

Return type:

str

stylize(text, style)[source]

Format text with the specified style.

Return type:

str