module documentation

termcolors.py
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
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
DARK_PALETTE: str =

Undocumented

Value
'dark'
LIGHT_PALETTE: str =

Undocumented

Value
'light'
NOCOLOR_PALETTE: str =

Undocumented

Value
'nocolor'
PALETTES =

Undocumented

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

Undocumented

Value
'0'
background =

Undocumented

color_names: tuple[str, ...] =

Undocumented

foreground =

Undocumented

opt_dict: dict[str, str] =

Undocumented

def colorize(text='', opts=(), **kwargs):

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):

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):

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'