in scripts/ebcli_installer.py [0:0]
def _print_in_foreground(message, color_number):
"""
Function prints a given `message` on the terminal in the foreground. `color_number`
is a number between and including 0 and 255. FOr a list of color codes see:
https://misc.flogisoft.com/bash/tip_colors_and_formatting#background1
On Windows, `color_number` is rejected, and hence not used. At present, PowerShell
is able to recognize ANSI/VT100 escape sequences, however, CMD prompt is not.
:param message: a string to print in the foreground on the terminal
:param color_number: an integer between and including 0 and 255 representing
a color
:return: None
"""
if sys.platform.startswith('win32'):
import colorama
colorama.init()
if color_number == GREEN_COLOR_CODE:
print(colorama.Fore.GREEN + message)
elif color_number == RED_COLOR_CODE:
print(colorama.Fore.RED + message)
elif color_number == YELLOW_COLOR_CODE:
print(colorama.Fore.LIGHTYELLOW_EX + message)
else:
print(message)
print(colorama.Style.RESET_ALL)
else:
# Courtesy https://misc.flogisoft.com/bash/tip_colors_and_formatting
print(
"\033[38;5;{color_number}m{message}\033[0m".format(
color_number=color_number,
message=message,
)
)