clr: Color Text Easily

Color text.

Typical usage:

>>> red('red text', False)

Returns the string “red text” where the text will be red and the background will be the default.

>>> red('red background')

Returns the string “red background” where the text will be the default color and the background will be red.

common.clr.add_color_log_levels(center=False)[source]

Alter log level names to be colored.

Levels are colored to have black text and a background colored as follows:

  • Level 50 (Critical): red
  • Level 40 (Error): magenta
  • Level 30 (Warning): yellow
  • Level 20 (Info): blue
  • Level 10 (Debug): green
  • Level 0 (Not Set): white
Parameters:center (bool) – If log text should be centered. When set to True, the text will be centered to the width of "CRITICAL", which is 8 characters. This makes it so the level in the log output always takes up the same number of characters.
Return type:None
common.clr.black(text, background=True)[source]

Set text (or its background) to be black.

common.clr.red(text, background=True)[source]

Set text (or its background) to be red.

common.clr.green(text, background=True)[source]

Set text (or its background) to be green.

common.clr.yellow(text, background=True)[source]

Set text (or its background) to be yellow.

common.clr.blue(text, background=True)[source]

Set text (or its background) to be blue.

common.clr.magenta(text, background=True)[source]

Set text (or its background) to be magenta.

common.clr.cyan(text, background=True)[source]

Set text (or its background) to be cyan.

common.clr.white(text, background=True)[source]

Set text (or its background) to be white.