utils.ievv_colorize — Colorized output for terminal stdout/stderr¶
-
ievv_opensource.utils.ievv_colorize.
COLOR_RED
= 'red'¶ Red color constant for
ievv_colorize()
.
-
ievv_opensource.utils.ievv_colorize.
COLOR_BLUE
= 'blue'¶ Blue color constant for
ievv_colorize()
.
-
ievv_opensource.utils.ievv_colorize.
COLOR_YELLOW
= 'yellow'¶ Yellow color constant for
ievv_colorize()
.
-
ievv_opensource.utils.ievv_colorize.
COLOR_GREY
= 'grey'¶ Grey color constant for
ievv_colorize()
.
-
ievv_opensource.utils.ievv_colorize.
COLOR_GREEN
= 'green'¶ Green color constant for
ievv_colorize()
.
-
ievv_opensource.utils.ievv_colorize.
colorize
(text, color, bold=False)[source]¶ Colorize a string for stdout/stderr.
Colors are only applied if
IEVV_COLORIZE_USE_COLORS
isTrue
or not defined (so it defaults toTrue
).Examples
Print blue text:
from ievv_opensource.utils import ievv_colorize print(ievv_colorize('Test', color=ievv_colorize.COLOR_BLUE))
Print bold red text:
print(ievv_colorize('Test', color=ievv_colorize.COLOR_RED, bold=True))
Parameters: - text – The text (string) to colorize.
- color –
The color to use. Should be one of:
COLOR_RED
COLOR_BLUE
COLOR_YELLOW
COLOR_GREY
COLOR_GREEN
None
(no color)
- bold – Set this to
True
to use bold font.