MCPcopy
hub / github.com/treeverse/dvc / colorize

Function colorize

dvc/utils/__init__.py:137–158  ·  view source on GitHub ↗

Returns a message in a specified color.

(message, color=None, style=None)

Source from the content-addressed store, hash-verified

135
136
137def colorize(message, color=None, style=None):
138 """Returns a message in a specified color."""
139 if not color:
140 return message
141
142 styles = {"dim": colorama.Style.DIM, "bold": colorama.Style.BRIGHT}
143
144 colors = {
145 "green": colorama.Fore.GREEN,
146 "yellow": colorama.Fore.YELLOW,
147 "blue": colorama.Fore.BLUE,
148 "red": colorama.Fore.RED,
149 "magenta": colorama.Fore.MAGENTA,
150 "cyan": colorama.Fore.CYAN,
151 }
152
153 return "{style}{color}{message}{reset}".format(
154 style=styles.get(style, ""),
155 color=colors.get(color, ""),
156 message=message,
157 reset=colorama.Style.RESET_ALL,
158 )
159
160
161def boxify(message, border_color=None):

Callers 5

_show_statusMethod · 0.90
_log_unknown_exceptionsFunction · 0.90
_format_exc_msgFunction · 0.90
formatMethod · 0.90
boxifyFunction · 0.70

Calls 2

formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected