Python colorama.Fore 模块,LIGHTBLACK_EX 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用colorama.Fore.LIGHTBLACK_EX

项目:bonobo    作者:python-bonobo    | 项目源码 | 文件源码
def filter(self, record):
        record.spent = record.relativeCreated // 1000
        if iswindows:
            record.fg = ''
        elif record.levelname == 'DEBG':
            record.fg = Fore.LIGHTBLACK_EX
        elif record.levelname == 'INFO':
            record.fg = Fore.LIGHTWHITE_EX
        elif record.levelname == 'WARN':
            record.fg = Fore.LIGHTYELLOW_EX
        elif record.levelname == 'ERR ':
            record.fg = Fore.LIGHTRED_EX
        elif record.levelname == 'CRIT':
            record.fg = Fore.RED
        else:
            record.fg = Fore.LIGHTWHITE_EX
        return True
项目:cftool    作者:guilhermeleobas    | 项目源码 | 文件源码
def print_output(obj):
    # to-do:
    # Error while executing code

    if obj['status'] != 0:
        print ( '~ Test #{} - '.format(obj['testcase']) + Fore.RED + 'ERROR')
        # In some cases the process spawn by cftool returns SIGSEGV (-11)
        # and process.stderr is empty
        if obj['stderr'] == '' and obj['status'] == -11:
            print ('Process exited with SIGSEGV, probably because of a segmentation fault')
        else:
            print (obj['stderr'])
        return

    # split time between numbers and letters
    m = re.split(r'(\d+)', obj['time'])
    if int(m[1]) >= 5 and m[2] in ['s', 'm', 'h']:
        print ( '~ Test #{} - '.format(obj['testcase']) + Fore.RED + '{}'.format(obj['time']) )
    else:
        print ( '~ Test #{} - {}'.format(obj['testcase'], obj['time']) )

    stdout = obj['stdout']
    expected = obj['expected']

    if compare_outputs(stdout, expected):
        print (Fore.GREEN + stdout)
        print ('')
    else:
        print (Fore.RED + stdout)
        print ('')
        print (Fore.LIGHTBLACK_EX + 'Expected:')
        print (Fore.LIGHTBLACK_EX + expected)
        print ('')
项目:bonobo-docker    作者:python-bonobo    | 项目源码 | 文件源码
def _enable_shell_colors():
    import sys
    from colorama import Fore
    sys.ps1 = Fore.LIGHTWHITE_EX + '?? >' + Fore.RESET + ' '
    sys.ps2 = Fore.BLACK + '..' + Fore.LIGHTBLACK_EX + '.' + Fore.RESET + ' '
项目:g3ar    作者:VillanCh    | 项目源码 | 文件源码
def print_gray(*args):
    """"""
    raw = str(args)
    init(autoreset=True)
    print((Fore.LIGHTBLACK_EX + raw))


#----------------------------------------------------------------------
项目:g3ar    作者:VillanCh    | 项目源码 | 文件源码
def print_gray(*args):
    """"""
    raw = str(args)
    init(autoreset=True)
    print((Fore.LIGHTBLACK_EX + raw))


#----------------------------------------------------------------------
项目:minihydra    作者:VillanCh    | 项目源码 | 文件源码
def print_gray(*args):
    """"""
    raw = str(args)
    init(autoreset=True)
    print((Fore.LIGHTBLACK_EX + raw))


#----------------------------------------------------------------------
项目:tensorflow-rl-tictactoe    作者:Russell-Ford    | 项目源码 | 文件源码
def dump_board(sx, so, move_index=None, win_indices=None, q=None):
    """
    Dump board state to the terminal.
    """
    for i in xrange(board_size):
        for j in xrange(board_size):
            if (i, j) == move_index:
                color = Fore.GREEN
            else:
                color = Fore.BLACK
            if not win_indices is None and (i, j) in win_indices:
                color += Back.LIGHTYELLOW_EX
            print(" ", end="")
            if sx[i, j] and so[i, j]:
                print(Fore.RED + "?" + Fore.RESET, end="")
            elif sx[i, j]:
                print(color + "X" + Style.RESET_ALL, end="")
            elif so[i, j]:
                print(color + "O" + Style.RESET_ALL, end="")
            else:
                print(".", end="")
        if not q is None:
            print("   ", end="")
            for j in xrange(board_size):
                if (i, j) == move_index:
                    color = Fore.GREEN
                else:
                    color = Fore.BLACK
                if not (sx[i, j] or so[i, j]) or (i, j) == move_index:
                    print(color + " %6.3f" % q[i, j] + Style.RESET_ALL, end="")
                else:
                    print(Fore.LIGHTBLACK_EX + "    *  " + Style.RESET_ALL, end="")
        print()
    print()
项目:pyLanguagetool    作者:Findus23    | 项目源码 | 文件源码
def print_errors(matches, api_url, version, print_color=True):
    def colored(text, color):
        if print_color:
            init_colors()
            return color + text + Fore.RESET
        else:
            return text

    tick = colored(u"\u2713", Fore.LIGHTGREEN_EX) + " "
    cross = colored(u"\u2717", Fore.LIGHTRED_EX) + " "

    for error in matches:
        context_object = error["context"]
        context = context_object["text"]
        length = context_object["length"]
        offset = context_object["offset"]

        endpostion = offset + length
        print(error["message"])

        print(
            indention[:2] +
            cross +
            colored(context[:offset], Fore.LIGHTBLACK_EX) +
            colored(context[offset:endpostion], Fore.LIGHTRED_EX) +
            colored(context[endpostion:], Fore.LIGHTBLACK_EX)
        )
        print(
            indention +
            offset * " " +
            colored(length * "^", Fore.LIGHTRED_EX)
        )

        if error["replacements"]:
            # only print first 5 replacements
            for replacement in error["replacements"][:5]:
                print(
                    indention[:2] +
                    tick +
                    colored(context[:offset], Fore.LIGHTBLACK_EX) +
                    colored(replacement["value"], Fore.LIGHTGREEN_EX) +
                    colored(context[endpostion:], Fore.LIGHTBLACK_EX)
                )
        print()
    print(colored("Text checked by {url} ({version})".format(url=api_url, version=version), Fore.LIGHTBLACK_EX))