Package pology :: Module colors

Module colors

Standard codes for terminal colors.


Authors:
Chusslove Illich <caslav.ilic@gmx.net>, Sébastien Renard <sebastien.renard@digitalfox.org>

License: GPLv3

Classes
  ColorString
Class for strings with color markup.
  ColorOptionParser
Lightweight wrapper for OptionParser from standard library optparse, to gracefully handle ColorString arguments supplied to its methods.
Functions
type(joiner)/ColorString
cjoin(strings, joiner=u'')
Join strings into a ColorString if any of them are ColorString, otherwise into type of joiner.
type(format)/ColorString
cinterp(format, *args, **kwargs)
Interpolate arguments into the format string, producing ColorString if any of the arguments is ColorString, otherwise type of format string.
 
get_coloring_types()
List of keywords of all available coloring types.
 
set_coloring_globals(ctype='term', outdep=True)
Set global options for coloring.
Variables
  __package__ = 'pology'
Function Details

cjoin(strings, joiner=u'')

 

Join strings into a ColorString if any of them are ColorString, otherwise into type of joiner.

Parameters:
  • strings (sequence of strings) - strings to join
  • joiner (string) - string to be inserted between each two strings
Returns: type(joiner)/ColorString
concatenation by joiner of all strings

cinterp(format, *args, **kwargs)

 

Interpolate arguments into the format string, producing ColorString if any of the arguments is ColorString, otherwise type of format string.

The format string can use either positional format directives, in which case positional arguments are supplied after it, or it can use named format directives, in which case keyword arguments are supplied after it. If both positional and keyword arguments are following the format string, the behavior is undefined.

Parameters:
  • format (string) - string with formatting directives
Returns: type(format)/ColorString
interpolated strings

set_coloring_globals(ctype='term', outdep=True)

 

Set global options for coloring.

ColorString.resolve will use the type of coloring given by ctype here whenever its own ctype is set to None.

If outdep is set to False, ColorString.resolve will not check the file descriptor given to it, and always use coloring type according to ctype.

Parameters:
  • ctype (string) - type of coloring
  • outdep (bool) - whether coloring depends on output file descriptor