1.5. color
¶
This module provides functions for converting and using colors for arbitrary purposes including terminal output.
1.5.1. Functions¶
-
convert_hex_to_tuple
(hex_color, raw=False)[source]¶ Converts an RGB hex triplet such as #ff0000 into an RGB tuple. If raw is True then each value is on a scale from 0 to 255 instead of 0.0 to 1.0.
Parameters: Returns: The color as a red, green, blue tuple.
Return type:
-
convert_tuple_to_hex
(rgb, raw=False)[source]¶ Converts an RGB color tuple info a hex string such as #ff0000. If raw is True then each value is treated as if it were on a scale from 0 to 255 instead of 0.0 to 1.0.
Parameters: Returns: The RGB color as a string.
Return type:
-
get_scale
(color_low, color_high, count, ascending=True)[source]¶ Create a scale of colors gradually moving from the low color to the high color.
Parameters: Returns: An array of colors starting with the low and gradually transitioning to the high.
Return type:
-
print_error
(message)[source]¶ Print an error message to the console.
Parameters: message (str) – The message to print
1.5.2. Classes¶
-
class
ColoredLogFormatter
(fmt=None, datefmt=None, style='%')[source]¶ A formatting class suitable for use with the
logging
module which colorizes the names of log levels.-
format
(record)[source]¶ Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
-