Color#
- class lsst.pex.config.history.Color(text, category)#
Bases:
objectA controller that determines whether strings should be colored.
Parameters#
- text
str Text content to print to a terminal.
- category
str Semantic category of the
text. Seecategoriesfor possible values.
Raises#
- RuntimeError
Raised when the
categoryis not a key ofColor.categories.
Notes#
The usual usage is
Color(string, category)which returns a string that may be printed; categories are given by the keys ofColor.categories.Color.colorizemay be used to set or retrieve whether the user wants color. It always returnsFalsewhensys.stdoutis not attached to a terminal.Attributes Summary
Mapping of semantic labels to color names (
dict).Mapping of color names to terminal color codes (
dict).Methods Summary
colorize([val])Get or set whether the string should be colorized.
Attributes Documentation
- categories = {'FILE': 'green', 'FUNCTION_NAME': 'blue', 'NAME': 'blue', 'TEXT': 'red', 'VALUE': 'yellow'}#
Mapping of semantic labels to color names (
dict).Notes#
The default categories are:
'NAME''VALUE''FILE''TEXT''FUNCTION_NAME'
- colors = {'black': 0, 'blue': 4, 'cyan': 6, 'green': 2, 'magenta': 5, 'red': 1, 'white': 7, 'yellow': 3}#
Mapping of color names to terminal color codes (
dict).
Methods Documentation
- static colorize(val=None)#
Get or set whether the string should be colorized.
Parameters#
- val
boolordict, optional The value is usually a bool, but it may be a dict which is used to modify
Color.categories.
Returns#
- shouldColorize
bool If
True, the string should be colorized. A string will not be colorized if standard output or standard error are not attached to a terminal or if thevalargument wasFalse.Only strings written to a terminal are colorized.
- val
- text