Source code for pygitrepo.color_print

# -*- coding: utf-8 -*-

"""
Utility module for colored text print in terminal.
"""

import os

from .pkg.mini_colorma import Fore, Style

TAB = " " * 2


[docs]def pgr_print(message): """ Syntax sugar for: [pygitrepo] ... message ... {Style.RESET_ALL} :type message: str """ print("[pygitrepo] {}{}".format(message, Style.RESET_ALL))
[docs]def pgr_print_done(indent=0): """ Syntax sugar for: [pygitrepo] {number_of_tab_indent}done :type indent: int """ print("{reset}[pygitrepo] {cyan}{indent}done{reset}".format( cyan=Fore.CYAN, reset=Style.RESET_ALL, indent=indent * TAB, ))
[docs]def colorful_path(path): """ :type path: str :rtype: str """ if os.path.exists(path): color = Fore.GREEN else: color = Fore.RED return "{color}{path}{reset}".format( color=color, path=path, reset=Style.RESET_ALL, )