pyCBD.tracers.color module

Helper file for color information when printing to the terminal.

class pyCBD.tracers.color.COLOR[source]

Bases: object

Color interface to write colored text to the console. This can be used to mark certain components of a trace, when writing to the console.

Colors may be combined using string concatenation (+).

Note

To make this work on Windows 10, VT100 emulation needs to be enabled. For other versions, ANSICON needs to be used. On other OS, it should work out-of-the-bag.

static colorize(text, *colors)[source]

Colors the text in a given set of colors and terminates the coloring at the end.

Parameters
  • text (str) – The text to color.

  • *colors – The colors for the text. May be given as a set of arguments, or as a concatenated string.

static uncolorize(text)[source]

Removes all colorization indicators from the string.

Parameters

text (str) – The string to remove color from.

static rainbow(text, colors=None)[source]

Colors each letter of the text in another color, based on the color list.

Parameters
  • text (str) – Text to color.

  • colors (iter) – An ordered sequence of colors. Defaults to the colors of the rainbow.

ENDC = '\x1b[0m'

Ends any coloring. Must be used at the end to prevent color “creep”.

BOLD = '\x1b[1m'

Makes the text bold.

DARK = '\x1b[2m'

Makes the text slightly darker.

ITALIC = '\x1b[3m'

Makes the text slanted/cursive/italic.

ULINE = '\x1b[4m'

Makes the text underlined.

Makes the text blink at the cursor blink rate.

HIGHLIGHT = '\x1b[7m'

Highlights the text by swapping foreground and background colors.

STRIKE = '\x1b[9m'

Draws a line through the text, commonly known as ‘strikethrough’.

UULINE = '\x1b[21m'

Makes the text doubly underlined.

OLINE = '\x1b[53m'

Makes the text overlined.

DARKGRAY = '\x1b[30m'

Makes the text dark gray (depends on the terminal palette).

RED = '\x1b[31m'

Makes the text red (depends on the terminal palette).

GREEN = '\x1b[32m'

Makes the text green (depends on the terminal palette).

YELLOW = '\x1b[33m'

Makes the text yellow (depends on the terminal palette).

BLUE = '\x1b[34m'

Makes the text blue (depends on the terminal palette).

PURPLE = '\x1b[35m'

Makes the text purple (depends on the terminal palette).

CYAN = '\x1b[36m'

Makes the text cyan (depends on the terminal palette).

LIGHTGRAY = '\x1b[37m'

Makes the text light gray (depends on the terminal palette).

BDARKGRAY = '\x1b[40m'

Makes the background dark gray (depends on the terminal palette).

BRED = '\x1b[41m'

Makes the background red (depends on the terminal palette).

BGREEN = '\x1b[42m'

Makes the background green (depends on the terminal palette).

BYELLOW = '\x1b[43m'

Makes the background yellow (depends on the terminal palette).

BBLUE = '\x1b[44m'

Makes the background blue (depends on the terminal palette).

BPURPLE = '\x1b[45m'

Makes the background purple (depends on the terminal palette).

BCYAN = '\x1b[46m'

Makes the background cyan (depends on the terminal palette).

BLIGHTGRAY = '\x1b[47m'

Makes the background light gray (depends on the terminal palette).

LDARKGRAY = '\x1b[90m'

Makes the text a lighter dark gray (depends on the terminal palette).

LRED = '\x1b[91m'

Makes the text a lighter red (depends on the terminal palette).

LGREEN = '\x1b[92m'

Makes the text a lighter green (depends on the terminal palette).

LYELLOW = '\x1b[93m'

Makes the text a lighter yellow (depends on the terminal palette).

LBLUE = '\x1b[94m'

Makes the text a lighter blue (depends on the terminal palette).

LPURPLE = '\x1b[95m'

Makes the text a lighter purple (depends on the terminal palette).

LCYAN = '\x1b[96m'

Makes the text a lighter cyan (depends on the terminal palette).

LLIGHTGRAY = '\x1b[97m'

Makes the text a lighter light gray (depends on the terminal palette).

BLDARKGRAY = '\x1b[100m'

Makes the background a lighter dark gray (depends on the terminal palette).

BLRED = '\x1b[101m'

Makes the background a lighter red (depends on the terminal palette).

BLGREEN = '\x1b[102m'

Makes the background a lighter green (depends on the terminal palette).

BLYELLOW = '\x1b[103m'

Makes the background a lighter yellow (depends on the terminal palette).

BLBLUE = '\x1b[104m'

Makes the background a lighter blue (depends on the terminal palette).

BLPURPLE = '\x1b[105m'

Makes the background a lighter purple (depends on the terminal palette).

BLCYAN = '\x1b[106m'

Makes the background a lighter cyan (depends on the terminal palette).

BLLIGHTGRAY = '\x1b[107m'

Makes the background a lighter light gray (depends on the terminal palette).