module documentation

termcolors.py

Function colorize Return your text, enclosed in ANSI graphics codes.
Function make_style Return a function with default parameters for colorize()
Function parse_color_setting Parse a DJANGO_COLORS environment variable to produce the system palette
Constant DARK_PALETTE Undocumented
Constant LIGHT_PALETTE Undocumented
Constant NOCOLOR_PALETTE Undocumented
Constant PALETTES Undocumented
Constant RESET Undocumented
Variable background Undocumented
Variable color_names Undocumented
Variable foreground Undocumented
Variable opt_dict Undocumented
def colorize(text='', opts=(), **kwargs): (source)

Return your text, enclosed in ANSI graphics codes. Depends on the keyword arguments 'fg' and 'bg', and the contents of the opts tuple/list. Return the RESET code if no parameters are given. Valid colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white' Valid options: 'bold' 'underscore' 'blink' 'reverse' 'conceal' 'noreset' - string will not be auto-terminated with the RESET code Examples: colorize('hello', fg='red', bg='blue', opts=('blink',)) colorize() colorize('goodbye', opts=('underscore',)) print(colorize('first line', fg='red', opts=('noreset',))) print('this should be red too') print(colorize('and so should this')) print('this should not be red')

def make_style(opts=(), **kwargs): (source)

Return a function with default parameters for colorize() Example: bold_red = make_style(opts=('bold',), fg='red') print(bold_red('hello')) KEYWORD = make_style(fg='yellow') COMMENT = make_style(fg='blue', opts=('bold',))

def parse_color_setting(config_string): (source)

Parse a DJANGO_COLORS environment variable to produce the system palette The general form of a palette definition is: "palette;role=fg;role=fg/bg;role=fg,option,option;role=fg/bg,option,option" where: palette is a named palette; one of 'light', 'dark', or 'nocolor'. role is a named style used by Django fg is a foreground color. bg is a background color. option is a display options. Specifying a named palette is the same as manually specifying the individual definitions for each role. Any individual definitions following the palette definition will augment the base palette definition. Valid roles: 'error', 'success', 'warning', 'notice', 'sql_field', 'sql_coltype', 'sql_keyword', 'sql_table', 'http_info', 'http_success', 'http_redirect', 'http_not_modified', 'http_bad_request', 'http_not_found', 'http_server_error', 'migrate_heading', 'migrate_label' Valid colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white' Valid options: 'bold', 'underscore', 'blink', 'reverse', 'conceal', 'noreset'

DARK_PALETTE: str = (source)

Undocumented

Value
'dark'
LIGHT_PALETTE: str = (source)

Undocumented

Value
'light'
NOCOLOR_PALETTE: str = (source)

Undocumented

Value
'nocolor'
PALETTES = (source)

Undocumented

Value
{NOCOLOR_PALETTE: {'ERROR': {},
                   'SUCCESS': {},
                   'WARNING': {},
                   'NOTICE': {},
                   'SQL_FIELD': {},
                   'SQL_COLTYPE': {},
                   'SQL_KEYWORD': {},
...

Undocumented

Value
'0'
background = (source)

Undocumented

color_names: tuple[str, ...] = (source)

Undocumented

foreground = (source)

Undocumented

opt_dict: dict[str, str] = (source)

Undocumented