Version: 9.12.0
termcolor
Collaboration diagram for termcolor:

Functions

def termcolor.canDisplayColor (stream)
 Return True if the stream can display colored text, False otherwise. More...
 
def termcolor.getControlSequence (color)
 Return the control sequence for the color in parameter, i.e. More...
 
def termcolor.makeColoredMessage (message, color)
 Return a string that can be used to display the message in parameter with the given color. More...
 
def termcolor.TEST_termcolor ()
 Test function for termcolor module. More...
 
def KERNEL_PY.kernel.termcolor.canDisplayColor (stream)
 Return True if the stream can display colored text, False otherwise. More...
 
def KERNEL_PY.kernel.termcolor.getControlSequence (color)
 Return the control sequence for the color in parameter, i.e. More...
 
def KERNEL_PY.kernel.termcolor.makeColoredMessage (message, color)
 Return a string that can be used to display the message in parameter with the given color. More...
 
def KERNEL_PY.kernel.termcolor.TEST_termcolor ()
 Test function for termcolor module. More...
 

Variables

list termcolor.DEFAULT = ['00']
 Default color for the terminal. More...
 
list termcolor.BOLD = ['01']
 Bold text and brighter colors. More...
 
list termcolor.UNDERLINED = ['04']
 Underlined text. More...
 
list termcolor.BLACK_FG = ['30']
 Black foreground. More...
 
list termcolor.RED_FG = ['31']
 Red foreground. More...
 
list termcolor.GREEN_FG = ['32']
 Green foreground. More...
 
list termcolor.YELLOW_FG = ['33']
 Yellow foreground. More...
 
list termcolor.BLUE_FG = ['34']
 Blue foreground. More...
 
list termcolor.PURPLE_FG = ['35']
 Purple foreground. More...
 
list termcolor.CYAN_FG = ['36']
 Cyan foreground. More...
 
list termcolor.WHITE_FG = ['37']
 White foreground. More...
 
list termcolor.BLACK_BG = ['40']
 Black background. More...
 
list termcolor.RED_BG = ['41']
 Red background. More...
 
list termcolor.GREEN_BG = ['42']
 Green background. More...
 
list termcolor.YELLOW_BG = ['43']
 Yellow background. More...
 
list termcolor.BLUE_BG = ['44']
 Blue background. More...
 
list termcolor.PURPLE_BG = ['45']
 Purple background. More...
 
list termcolor.CYAN_BG = ['46']
 Cyan background. More...
 
list termcolor.WHITE_BG = ['47']
 White background. More...
 
list termcolor.BLACK = BLACK_FG
 Black text (equivalent to BLACK_FG) More...
 
list termcolor.RED = BOLD + RED_FG
 Red text (equivalent to BOLD + RED_FG) More...
 
list termcolor.GREEN = BOLD + GREEN_FG
 Green text (equivalent to BOLD + GREEN_FG) More...
 
list termcolor.YELLOW = BOLD + YELLOW_FG
 Yellow text (equivalent to BOLD + YELLOW_FG) More...
 
list termcolor.BLUE = BOLD + BLUE_FG
 Blue text (equivalent to BOLD + BLUE_FG) More...
 
list termcolor.PURPLE = BOLD + PURPLE_FG
 Purple text (equivalent to BOLD + PURPLE_FG) More...
 
list termcolor.CYAN = BOLD + CYAN_FG
 Cyan text (equivalent to BOLD + CYAN_FG) More...
 
list termcolor.WHITE = WHITE_FG
 White text (equivalent to WHITE_FG) More...
 
list KERNEL_PY.kernel.termcolor.DEFAULT = ['00']
 Default color for the terminal. More...
 
list KERNEL_PY.kernel.termcolor.BOLD = ['01']
 Bold text and brighter colors. More...
 
list KERNEL_PY.kernel.termcolor.UNDERLINED = ['04']
 Underlined text. More...
 
list KERNEL_PY.kernel.termcolor.BLACK_FG = ['30']
 Black foreground. More...
 
list KERNEL_PY.kernel.termcolor.RED_FG = ['31']
 Red foreground. More...
 
list KERNEL_PY.kernel.termcolor.GREEN_FG = ['32']
 Green foreground. More...
 
list KERNEL_PY.kernel.termcolor.YELLOW_FG = ['33']
 Yellow foreground. More...
 
list KERNEL_PY.kernel.termcolor.BLUE_FG = ['34']
 Blue foreground. More...
 
list KERNEL_PY.kernel.termcolor.PURPLE_FG = ['35']
 Purple foreground. More...
 
list KERNEL_PY.kernel.termcolor.CYAN_FG = ['36']
 Cyan foreground. More...
 
list KERNEL_PY.kernel.termcolor.WHITE_FG = ['37']
 White foreground. More...
 
list KERNEL_PY.kernel.termcolor.BLACK_BG = ['40']
 Black background. More...
 
list KERNEL_PY.kernel.termcolor.RED_BG = ['41']
 Red background. More...
 
list KERNEL_PY.kernel.termcolor.GREEN_BG = ['42']
 Green background. More...
 
list KERNEL_PY.kernel.termcolor.YELLOW_BG = ['43']
 Yellow background. More...
 
list KERNEL_PY.kernel.termcolor.BLUE_BG = ['44']
 Blue background. More...
 
list KERNEL_PY.kernel.termcolor.PURPLE_BG = ['45']
 Purple background. More...
 
list KERNEL_PY.kernel.termcolor.CYAN_BG = ['46']
 Cyan background. More...
 
list KERNEL_PY.kernel.termcolor.WHITE_BG = ['47']
 White background. More...
 
list KERNEL_PY.kernel.termcolor.BLACK = BLACK_FG
 Black text (equivalent to BLACK_FG) More...
 
list KERNEL_PY.kernel.termcolor.RED = BOLD + RED_FG
 Red text (equivalent to BOLD + RED_FG) More...
 
list KERNEL_PY.kernel.termcolor.GREEN = BOLD + GREEN_FG
 Green text (equivalent to BOLD + GREEN_FG) More...
 
list KERNEL_PY.kernel.termcolor.YELLOW = BOLD + YELLOW_FG
 Yellow text (equivalent to BOLD + YELLOW_FG) More...
 
list KERNEL_PY.kernel.termcolor.BLUE = BOLD + BLUE_FG
 Blue text (equivalent to BOLD + BLUE_FG) More...
 
list KERNEL_PY.kernel.termcolor.PURPLE = BOLD + PURPLE_FG
 Purple text (equivalent to BOLD + PURPLE_FG) More...
 
list KERNEL_PY.kernel.termcolor.CYAN = BOLD + CYAN_FG
 Cyan text (equivalent to BOLD + CYAN_FG) More...
 
list KERNEL_PY.kernel.termcolor.WHITE = WHITE_FG
 White text (equivalent to WHITE_FG) More...
 

Detailed Description

This module provides utility functions to display colored text in the terminal. It is based on ISO 6429 standard that defines control codes to change characters representation in color-capable ASCII terminals.

In this module, colors are represented as lists of codes, so they can be added to obtain special effects (e.g. RED + GREEN_BG to display red text on green background). Several constants are defined for the most usual codes to facilitate the use of colors, but it is also possible to define colors directly from the corresponding code from ISO 6429 standard. In fact it is even necessary for less usual codes that don't have an associated constant (e.g. PURPLE + ['09'] can be used to display a crossed-out purple text).

import sys
from salome.kernel import termcolor
print(termcolor.makeColoredMessage("Hello world!", termcolor.BLUE))
else:
print("Hello world!")
def canDisplayColor(stream)
Return True if the stream can display colored text, False otherwise.
Definition: termcolor.py:138
def makeColoredMessage(message, color)
Return a string that can be used to display the message in parameter with the given color.
Definition: termcolor.py:156

Function Documentation

◆ canDisplayColor() [1/2]

◆ canDisplayColor() [2/2]

def KERNEL_PY.kernel.termcolor.canDisplayColor (   stream)

Return True if the stream can display colored text, False otherwise.

Return True if the stream can display colored text, False otherwise.

Referenced by KERNEL_PY.kernel.termcolor.TEST_termcolor().

◆ getControlSequence() [1/2]

def termcolor.getControlSequence (   color)

Return the control sequence for the color in parameter, i.e.

the string telling the terminal to display the following text in the given color.

Referenced by makeColoredMessage(), logger.Logger.setColor(), and KERNEL_PY.kernel.logger.Logger.setColor().

◆ getControlSequence() [2/2]

def KERNEL_PY.kernel.termcolor.getControlSequence (   color)

Return the control sequence for the color in parameter, i.e.

the string telling the terminal to display the following text in the given color.

Return the control sequence for the color in parameter, i.e. the string
telling the terminal to display the following text in the given color.

Referenced by KERNEL_PY.kernel.termcolor.makeColoredMessage().

◆ makeColoredMessage() [1/2]

def termcolor.makeColoredMessage (   message,
  color 
)

Return a string that can be used to display the message in parameter with the given color.

References getControlSequence().

Referenced by deprecation.__show_colored_warning(), KERNEL_PY.kernel.deprecation.__show_colored_warning(), pyunittester.printfile(), KERNEL_PY.kernel.pyunittester.printfile(), and TEST_termcolor().

◆ makeColoredMessage() [2/2]

def KERNEL_PY.kernel.termcolor.makeColoredMessage (   message,
  color 
)

Return a string that can be used to display the message in parameter with the given color.

Return a string that can be used to display the message in parameter with
the given color.

References KERNEL_PY.kernel.termcolor.getControlSequence().

Referenced by KERNEL_PY.kernel.termcolor.TEST_termcolor().

◆ TEST_termcolor() [1/2]

def termcolor.TEST_termcolor ( )

Test function for termcolor module.

References canDisplayColor(), and makeColoredMessage().

◆ TEST_termcolor() [2/2]

def KERNEL_PY.kernel.termcolor.TEST_termcolor ( )

Test function for termcolor module.

Test function for termcolor module.

References KERNEL_PY.kernel.termcolor.canDisplayColor(), and KERNEL_PY.kernel.termcolor.makeColoredMessage().

Variable Documentation

◆ BLACK [1/2]

list termcolor.BLACK = BLACK_FG

Black text (equivalent to BLACK_FG)

◆ BLACK [2/2]

list KERNEL_PY.kernel.termcolor.BLACK = BLACK_FG

Black text (equivalent to BLACK_FG)

◆ BLACK_BG [1/2]

list termcolor.BLACK_BG = ['40']

Black background.

◆ BLACK_BG [2/2]

list KERNEL_PY.kernel.termcolor.BLACK_BG = ['40']

Black background.

◆ BLACK_FG [1/2]

list termcolor.BLACK_FG = ['30']

Black foreground.

◆ BLACK_FG [2/2]

list KERNEL_PY.kernel.termcolor.BLACK_FG = ['30']

Black foreground.

◆ BLUE [1/2]

list termcolor.BLUE = BOLD + BLUE_FG

Blue text (equivalent to BOLD + BLUE_FG)

◆ BLUE [2/2]

list KERNEL_PY.kernel.termcolor.BLUE = BOLD + BLUE_FG

Blue text (equivalent to BOLD + BLUE_FG)

◆ BLUE_BG [1/2]

list termcolor.BLUE_BG = ['44']

Blue background.

◆ BLUE_BG [2/2]

list KERNEL_PY.kernel.termcolor.BLUE_BG = ['44']

Blue background.

◆ BLUE_FG [1/2]

list termcolor.BLUE_FG = ['34']

Blue foreground.

◆ BLUE_FG [2/2]

list KERNEL_PY.kernel.termcolor.BLUE_FG = ['34']

Blue foreground.

◆ BOLD [1/2]

list termcolor.BOLD = ['01']

Bold text and brighter colors.

◆ BOLD [2/2]

list KERNEL_PY.kernel.termcolor.BOLD = ['01']

Bold text and brighter colors.

◆ CYAN [1/2]

list termcolor.CYAN = BOLD + CYAN_FG

Cyan text (equivalent to BOLD + CYAN_FG)

◆ CYAN [2/2]

list KERNEL_PY.kernel.termcolor.CYAN = BOLD + CYAN_FG

Cyan text (equivalent to BOLD + CYAN_FG)

◆ CYAN_BG [1/2]

list termcolor.CYAN_BG = ['46']

Cyan background.

◆ CYAN_BG [2/2]

list KERNEL_PY.kernel.termcolor.CYAN_BG = ['46']

Cyan background.

◆ CYAN_FG [1/2]

list termcolor.CYAN_FG = ['36']

Cyan foreground.

◆ CYAN_FG [2/2]

list KERNEL_PY.kernel.termcolor.CYAN_FG = ['36']

Cyan foreground.

◆ DEFAULT [1/2]

list termcolor.DEFAULT = ['00']

Default color for the terminal.

◆ DEFAULT [2/2]

list KERNEL_PY.kernel.termcolor.DEFAULT = ['00']

Default color for the terminal.

◆ GREEN [1/2]

list termcolor.GREEN = BOLD + GREEN_FG

Green text (equivalent to BOLD + GREEN_FG)

◆ GREEN [2/2]

list KERNEL_PY.kernel.termcolor.GREEN = BOLD + GREEN_FG

Green text (equivalent to BOLD + GREEN_FG)

◆ GREEN_BG [1/2]

list termcolor.GREEN_BG = ['42']

Green background.

◆ GREEN_BG [2/2]

list KERNEL_PY.kernel.termcolor.GREEN_BG = ['42']

Green background.

◆ GREEN_FG [1/2]

list termcolor.GREEN_FG = ['32']

Green foreground.

◆ GREEN_FG [2/2]

list KERNEL_PY.kernel.termcolor.GREEN_FG = ['32']

Green foreground.

◆ PURPLE [1/2]

list termcolor.PURPLE = BOLD + PURPLE_FG

Purple text (equivalent to BOLD + PURPLE_FG)

◆ PURPLE [2/2]

list KERNEL_PY.kernel.termcolor.PURPLE = BOLD + PURPLE_FG

Purple text (equivalent to BOLD + PURPLE_FG)

◆ PURPLE_BG [1/2]

list termcolor.PURPLE_BG = ['45']

Purple background.

◆ PURPLE_BG [2/2]

list KERNEL_PY.kernel.termcolor.PURPLE_BG = ['45']

Purple background.

◆ PURPLE_FG [1/2]

list termcolor.PURPLE_FG = ['35']

Purple foreground.

◆ PURPLE_FG [2/2]

list KERNEL_PY.kernel.termcolor.PURPLE_FG = ['35']

Purple foreground.

◆ RED [1/2]

list termcolor.RED = BOLD + RED_FG

Red text (equivalent to BOLD + RED_FG)

◆ RED [2/2]

list KERNEL_PY.kernel.termcolor.RED = BOLD + RED_FG

Red text (equivalent to BOLD + RED_FG)

◆ RED_BG [1/2]

list termcolor.RED_BG = ['41']

Red background.

◆ RED_BG [2/2]

list KERNEL_PY.kernel.termcolor.RED_BG = ['41']

Red background.

◆ RED_FG [1/2]

list termcolor.RED_FG = ['31']

Red foreground.

◆ RED_FG [2/2]

list KERNEL_PY.kernel.termcolor.RED_FG = ['31']

Red foreground.

◆ UNDERLINED [1/2]

list termcolor.UNDERLINED = ['04']

Underlined text.

◆ UNDERLINED [2/2]

list KERNEL_PY.kernel.termcolor.UNDERLINED = ['04']

Underlined text.

◆ WHITE [1/2]

list termcolor.WHITE = WHITE_FG

White text (equivalent to WHITE_FG)

◆ WHITE [2/2]

list KERNEL_PY.kernel.termcolor.WHITE = WHITE_FG

White text (equivalent to WHITE_FG)

◆ WHITE_BG [1/2]

list termcolor.WHITE_BG = ['47']

White background.

◆ WHITE_BG [2/2]

list KERNEL_PY.kernel.termcolor.WHITE_BG = ['47']

White background.

◆ WHITE_FG [1/2]

list termcolor.WHITE_FG = ['37']

White foreground.

◆ WHITE_FG [2/2]

list KERNEL_PY.kernel.termcolor.WHITE_FG = ['37']

White foreground.

◆ YELLOW [1/2]

list termcolor.YELLOW = BOLD + YELLOW_FG

Yellow text (equivalent to BOLD + YELLOW_FG)

◆ YELLOW [2/2]

list KERNEL_PY.kernel.termcolor.YELLOW = BOLD + YELLOW_FG

Yellow text (equivalent to BOLD + YELLOW_FG)

◆ YELLOW_BG [1/2]

list termcolor.YELLOW_BG = ['43']

Yellow background.

◆ YELLOW_BG [2/2]

list KERNEL_PY.kernel.termcolor.YELLOW_BG = ['43']

Yellow background.

◆ YELLOW_FG [1/2]

list termcolor.YELLOW_FG = ['33']

Yellow foreground.

◆ YELLOW_FG [2/2]

list KERNEL_PY.kernel.termcolor.YELLOW_FG = ['33']

Yellow foreground.