plainbox.impl.color
– ANSI color codes¶
-
class
plainbox.impl.color.
Colorizer
(color=None)[source]¶ Bases:
object
Colorizing helper for various kinds of content we need to handle
-
custom
(text, ansi_code)[source]¶ Render a piece of text with custom ANSI styling sequence
Parameters: - text – The text to stylize
- ansi_code – A string containing ANSI escape sequence to use.
Returns: A combination of
ansi_code
,text
and a fixed reset sequence that resets text styles.Note
When the colorizer is not really doing anything (see
is_enabled()
) then custom text is not used at all. This is done to ensure that any custom styling is not permantently enabled if colors are to be disabled.
-
is_enabled
¶ if true, this colorizer is actually using colors
This property is useful to let applications customize their behavior if they know color support is desired and enabled.
-
-
class
plainbox.impl.color.
ansi_off
[source]¶ Bases:
object
-
class
b
[source]¶ Bases:
object
-
BLACK
= ''¶
-
BLUE
= ''¶
-
CYAN
= ''¶
-
GREEN
= ''¶
-
MAGENTA
= ''¶
-
RED
= ''¶
-
RESET
= ''¶
-
WHITE
= ''¶
-
YELLOW
= ''¶
-
-
class
-
class
plainbox.impl.color.
ansi_on
[source]¶ Bases:
object
ANSI control codes for various useful stuff. Reference source: wikipedia
-
class
b
[source]¶ Bases:
object
Background color attributes
-
BLACK
= '\x1b[40m'¶
-
BLUE
= '\x1b[44m'¶
-
CYAN
= '\x1b[46m'¶
-
GREEN
= '\x1b[42m'¶
-
MAGENTA
= '\x1b[45m'¶
-
RED
= '\x1b[41m'¶
-
RESET
= '\x1b[49m'¶
-
WHITE
= '\x1b[47m'¶
-
YELLOW
= '\x1b[44m'¶
-
-
class
-
plainbox.impl.color.
get_color_for_tty
(stream=None)[source]¶ Get
ansi_on
if stdout is a tty,ansi_off
otherwise.Parameters: stream – Alternate stream to use (sys.stdout by default) Returns: ansi_on
oransi_off
, depending on if the stream being a tty or not.
-
plainbox.impl.color.
obj_off
¶ alias of
s
-
plainbox.impl.color.
obj_on
¶ alias of
s