Back to index

salome-kernel  6.5.0
Functions | Variables
KERNEL_PY.kernel.termcolor Namespace Reference

Functions

def canDisplayColor
def getControlSequence
def makeColoredMessage
def TEST_termcolor

Variables

list DEFAULT = ['00']
list BOLD = ['01']
list UNDERLINED = ['04']
list BLACK_FG = ['30']
list RED_FG = ['31']
list GREEN_FG = ['32']
list YELLOW_FG = ['33']
list BLUE_FG = ['34']
list PURPLE_FG = ['35']
list CYAN_FG = ['36']
list WHITE_FG = ['37']
list BLACK_BG = ['40']
list RED_BG = ['41']
list GREEN_BG = ['42']
list YELLOW_BG = ['43']
list BLUE_BG = ['44']
list PURPLE_BG = ['45']
list CYAN_BG = ['46']
list WHITE_BG = ['47']
 BLACK = BLACK_FG
 RED = BOLD+RED_FG
 GREEN = BOLD+GREEN_FG
 YELLOW = BOLD+YELLOW_FG
 BLUE = BOLD+BLUE_FG
 PURPLE = BOLD+PURPLE_FG
 CYAN = BOLD+CYAN_FG
 WHITE = WHITE_FG

Function Documentation

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

Definition at line 107 of file termcolor.py.

00107 
00108 def canDisplayColor(stream):
00109     """
00110     Return True if the stream can display colored text, False otherwise.
00111     """
00112     return hasattr(stream, "isatty") and stream.isatty()

Here is the caller graph for this function:

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.

Definition at line 113 of file termcolor.py.

00113 
00114 def getControlSequence(color):
00115     """
00116     Return the control sequence for the color in parameter, i.e. the string
00117     telling the terminal to display the following text in the given color.
00118     """
00119     seq = "\x1b["
00120     for i in range(len(color)):
00121         seq += color[i]
00122         if i < len(color)-1:
00123             seq += ";"
00124     seq += "m"
00125     return seq

Here is the caller graph for this function:

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.

Definition at line 126 of file termcolor.py.

00126 
00127 def makeColoredMessage(message, color):
00128     """
00129     Return a string that can be used to display the message in parameter with
00130     the given color.
00131     """
00132     return (getControlSequence(color) +
00133             str(message) +
00134             getControlSequence(DEFAULT))

Here is the call graph for this function:

Here is the caller graph for this function:

Test function for termcolor module.

Definition at line 135 of file termcolor.py.

00135 
00136 def TEST_termcolor():
00137     """Test function for termcolor module."""
00138     import sys
00139     if not canDisplayColor(sys.stdout):
00140         print "Standard output does not support colors."
00141         return
00142     print makeColoredMessage("This message must appear in blue.", BLUE)
00143     print makeColoredMessage("This message must appear in red on green " +
00144                              "background.", RED + GREEN_BG)
00145     print makeColoredMessage("This message must appear in magenta and " +
00146                              "crossed-out.", PURPLE + ['09'])
00147 
00148 
# Main function only used to test the module

Here is the call graph for this function:


Variable Documentation

Definition at line 89 of file termcolor.py.

Definition at line 71 of file termcolor.py.

Definition at line 55 of file termcolor.py.

Definition at line 97 of file termcolor.py.

Definition at line 79 of file termcolor.py.

Definition at line 63 of file termcolor.py.

Definition at line 51 of file termcolor.py.

Definition at line 101 of file termcolor.py.

Definition at line 83 of file termcolor.py.

Definition at line 67 of file termcolor.py.

Definition at line 49 of file termcolor.py.

Definition at line 93 of file termcolor.py.

Definition at line 75 of file termcolor.py.

Definition at line 59 of file termcolor.py.

Definition at line 99 of file termcolor.py.

Definition at line 81 of file termcolor.py.

Definition at line 65 of file termcolor.py.

Definition at line 91 of file termcolor.py.

Definition at line 73 of file termcolor.py.

Definition at line 57 of file termcolor.py.

Definition at line 53 of file termcolor.py.

Definition at line 103 of file termcolor.py.

Definition at line 85 of file termcolor.py.

Definition at line 69 of file termcolor.py.

Definition at line 95 of file termcolor.py.

Definition at line 77 of file termcolor.py.

Definition at line 61 of file termcolor.py.