def _get_color_printer(stream=sys.stdout, colors=True):
"""
Return a print function tied to a particular stream, along with coloring info.
"""
try:
from colorama import init, Fore, Back, Style
init(autoreset=True)
except ImportError:
Fore = Back = Style = _NoColor()
if not colors:
Fore = Back = Style = _NoColor()
def color_print(s, fore='', color='', end=''):
"""
"""
print(color + s, file=stream, end='')
print(Style.RESET_ALL, file=stream, end='')
print(end=end)
return color_print, Fore, Back, Style
评论列表
文章目录