1 # Copyright (c) 2020 Deutsche Telekom.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 """These are ANSI shell coloring codes used to format strings.
13 [ begins the color definition. \033 starts the escape sequence.
14 [\0330m is the default color of the shell that closes the escape sequence.
16 `FMT_STR` takes the color as its first parameter (int). As the second
17 parameter its takes the text (str).
20 Examples on ANSI colors, attributes, backgrounds and foregrounds:
21 https://stackoverflow.com/a/28938235/7619961
25 HIGHLIGHT_TAG = "highlight"
26 ATTRIBUTE_TAG = "attribute"
29 FMT_STR = "\033[%dm%s"
69 MDC and MARKER options are used only with Python starting 3.2 due to an update
70 in the logging module. This allows the use of %-formatting, :meth:`str.format`
71 (``{}``) formatting or :class:`string.Template` in the format string.