Python colorama.Style 模块,NORMAL 实例源码

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

项目:requests-arcgis-auth    作者:DOI-BLM    | 项目源码 | 文件源码
def main():
    colorama.init()
    # gratuitous use of lambda.
    pos = lambda y, x: '\x1b[%d;%dH' % (y, x)
    # draw a white border.
    print(Back.WHITE, end='')
    print('%s%s' % (pos(MINY, MINX), ' '*MAXX), end='')
    for y in range(MINY, 1+MAXY):
        print('%s %s ' % (pos(y, MINX), pos(y, MAXX)), end='')
    print('%s%s' % (pos(MAXY, MINX), ' '*MAXX), end='')
    # draw some blinky lights for a while.
    for i in range(PASSES):
        print('%s%s%s%s%s' % (pos(randint(1+MINY,MAXY-1), randint(1+MINX,MAXX-1)), choice(FORES), choice(BACKS), choice(STYLES), choice(CHARS)), end='')
    # put cursor to top, left, and set color to white-on-black with normal brightness.
    print('%s%s%s%s' % (pos(MINY, MINX), Fore.WHITE, Back.BLACK, Style.NORMAL), end='')
项目:radio-chan    作者:HanakiKaorin    | 项目源码 | 文件源码
def radio_play(s):
    global prev, song, voice, player

    if (len(s) > 4):
        song = yt[s]
        player = voice.create_ffmpeg_player(ytDir + song['file'], before_options='-hide_banner -loglevel panic', options='-b:a 64k -bufsize 64k')
        player.start()
        dprint(Fore.MAGENTA + 'Playing:' + Style.NORMAL + ' [YT] ' + song['artist'] + ' - ' +  song['title'])
    else:
        song = songListByID[s]
        player = voice.create_ffmpeg_player(musicDir + song['file'], before_options='-hide_banner -loglevel panic', options='-b:a 64k -bufsize 64k')
        player.start()
        if (song['artist']):
            dprint(Fore.MAGENTA + 'Playing:' + Style.NORMAL + ' [' + song['id'] + '] ' + song['artist'] + ' - ' + song['title'])
        else:
            dprint(Fore.MAGENTA + 'Playing:' + Style.NORMAL + ' [' + song['id'] + '] ' + song['title'])

    await client.change_status(game=discord.Game(name=song['title'], url='', type=0), idle=False)
    prev.append(song['id'])
    if (len(prev) > 5):
        prev.remove(prev[0])
    return player
项目:skymod    作者:DelusionalLogic    | 项目源码 | 文件源码
def yes_no(question, default="yes"):
    """Ask a yes/no question via input() and return their answer.

    "question" is a string that is presented to the user.
    "default" is the presumed answer if the user just hits <Enter>.
        It must be "yes" (the default), "no" or None (meaning
        an answer is required of the user).

    The "answer" return value is True for "yes" or False for "no".
    """
    valid = {"yes": True, "y": True, "ye": True,
             "no": False, "n": False}
    if default is None:
        prompt = " [y/n] "
    elif default == "yes":
        prompt = " [Y/n] "
    elif default == "no":
        prompt = " [y/N] "
    else:
        raise ValueError("invalid default answer: '%s'" % default)

    while True:
        sys.stdout.write(Style.BRIGHT + Fore.BLUE + ":: " + Fore.RESET + question + prompt + Style.NORMAL)
        choice = input().lower()
        if default is not None and choice == '':
            return valid[default]
        elif choice in valid:
            return valid[choice]
        else:
            sys.stdout.write("Please respond with 'yes' or 'no' "
                             "(or 'y' or 'n').\n")
项目:binarly-query    作者:binarlyhq    | 项目源码 | 文件源码
def show_row(row):
    row = color_row(row)
    print(" ".join(["%s%s%s:%s" % (Style.NORMAL, x.capitalize(), Style.BRIGHT, y) for (x, y) in row.items()]))
项目:MailFail    作者:m0rtem    | 项目源码 | 文件源码
def print_out(data):
    datetimestr = str(datetime.datetime.strftime(datetime.datetime.now(), '%H:%M:%S'))
    print(Style.NORMAL + "[" + datetimestr + "] " + data + Style.RESET_ALL)
项目:screeps_console    作者:screepers    | 项目源码 | 文件源码
def parseLine(line):
    severity = getSeverity(line)

    # Add color based on severity
    if 'severity' not in locals():
        severity = 3

    if severity == 0:
        color = Style.DIM + Fore.WHITE
    elif severity == 1:
        color = Style.NORMAL + Fore.BLUE
    elif severity == 2:
        color = Style.NORMAL + Fore.CYAN
    elif severity == 3:
        color = Style.NORMAL + Fore.WHITE
    elif severity == 4:
        color = Style.NORMAL + Fore.RED
    elif severity == 5:
        color = Style.NORMAL + Fore.BLACK + Back.RED
    else:
        color = Style.NORMAL + Fore.BLACK + Back.YELLOW

    # Replace html tab entity with actual tabs
    line = clearTags(line)
    line = line.replace('&#09;', "\t")
    return color + line + Style.RESET_ALL
项目:radio-chan    作者:HanakiKaorin    | 项目源码 | 文件源码
def yt_queue(s, m):
    global prev, song, voice, player, yt

    ydl_opts = {
        'format': 'bestaudio/best',
        'noplaylist': True,
        'nocheckcertificate': True,
        'quiet': True,
        'outtmpl': ytDir + '%(id)s',
        'default_search': 'auto'
    }

    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        meta = ydl.extract_info(s, download=False)
    yt[meta['id']] = {
        'id': meta['id'],
        'title': meta['title'],
        'artist': meta['uploader'],
        'album': 'YouTube',
        'composer': None, # meta['view_count'] / meta['like_count'] / meta['dislike_count']
        'length': meta['duration'],
        'file': meta['id']
    }

    if (meta['id'] in prev):
        mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ has already been played recently'
    elif (meta['id'] in queue):
        mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ is already in the queue'
    elif (meta['duration'] > 900):
        mainMessage = '[' + m.author.display_name + ']?The song [YT] _' + meta['title'] + '_ is too long (max 15 minutes)'
    else:
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([s])
        queue.append(meta['id'])
        dprint(Fore.MAGENTA + m.author.display_name + ' queued:' + Style.NORMAL + ' [YT] ' + meta['uploader'] + ' - ' +  meta['title'])
        mainMessage = '[' + m.author.display_name + ']?Queued [YT] _' + meta['title'] + '_'

    await client.send_message(m.channel, mainMessage)
    if (m.server): await client.delete_message(m)
项目:Shiro    作者:ffao    | 项目源码 | 文件源码
def cprint(s, log_level):
        colors = {
            'debug': (Fore.WHITE, Style.NORMAL),
            'info': (Fore.CYAN, Style.NORMAL),
            'warning': (Fore.YELLOW, Style.BRIGHT),
            'error': (Fore.RED, Style.BRIGHT),
            'default': (Fore.WHITE, Style.NORMAL)
        }
        color = (colors[log_level] if log_level in colors else colors['default'])
        print(color[0], end='')
        print(color[1], end='')
        print(s)
        print(Style.RESET_ALL)
项目:fish-hook    作者:dcalsky    | 项目源码 | 文件源码
def create_initialization_info(directory_name):
    print(GET_STARTED_INFO.format(
        fore_black=Fore.BLACK, back_green=Back.GREEN, fore_white=Fore.WHITE, fore_reset=Fore.RESET, back_reset=Back.RESET,
        style_bright=Style.BRIGHT, style_normal=Style.NORMAL, fore_green=Fore.GREEN,
        dir_name=directory_name
    ))
项目:PacPaw    作者:Sreyas-Sreelal    | 项目源码 | 文件源码
def warning( str ):
    print( Style.BRIGHT + Fore.RED + "[WARNING!]" + Style.NORMAL + str );
项目:hurt    作者:io-digital    | 项目源码 | 文件源码
def main(hits, workers, url, timeout):

    global _timeout, durations, result_codes, update_ui_now
    _timeout = timeout
    print ""
    print Fore.CYAN + 'PAIN IS GOOD  v0.0001              ' + Style.RESET_ALL
    print ""
    print '%sHitting: %s%s' % (Style.DIM, Style.NORMAL, url)
    print '%sHits:    %s%s%s' % (Style.DIM, Style.NORMAL, locale.format("%d", hits, grouping=True), Style.NORMAL)
    print '%sWorkers: %s%s%s' % (Style.DIM, Style.NORMAL, locale.format("%d", workers, grouping=True), Style.NORMAL)
    print '%sTimeout: %s%s seconds%s' % (Style.DIM, Style.NORMAL, timeout, Style.NORMAL)

    main_start = time.time()
    print Style.DIM + '\nStarting Workers...' + Style.RESET_ALL,
    sys.stdout.flush()

    for i in range(workers):
        t = Thread(target=do_work)
        t.daemon = True
        t.start()
    print ' Done.'

    print "\n" + Fore.CYAN + "Result Codes:" + Style.NORMAL

    ui = Thread(target=update_ui)
    ui.daemon = True
    ui.start()

    try:
        for i in range(hits):
            q.put(url.strip())

        q.join()

    except KeyboardInterrupt:
        sys.exit(1)

    _update_ui()
    update_ui_now = False

    print ""

    total_seconds = time.time()-main_start

    print "Total time: %.2f seconds." % total_seconds

    if '200 OK' in result_codes:
        print "Successful Requests Per Second: %.2f" % (result_codes['200 OK'] / total_seconds)

    if durations:
        print "Average response: %.2f seconds." % (reduce(lambda x, y: x + y, durations) / len(durations))
        print "Longest Response: %.2f seconds" % max(durations)
        print "Quickest Response: %.2f seconds" % min(durations)

    if elapsed:
        print "Longest Elapsed: %.2f seconds" % max(elapsed)
        print "Quickest Elapsed: %.2f seconds" % min(elapsed)

    print ""
项目:mo    作者:thomasleese    | 项目源码 | 文件源码
def output(self, event):
        if event.name in self.ignored_events:
            return

        character_style = self.get_character_style(event)
        character = self.get_character(event)
        text_style = self.get_text_style(event)

        if event.name == 'RunningTask':
            text = f'Running task: {Style.NORMAL}{event.args["task"].name}'
        elif event.name == 'SkippingTask':
            text = f'Skipping task: {Style.NORMAL}{event.args["name"]}'
        elif event.name == 'RunningCommand':
            text = f'Executing: {Style.NORMAL}{event.args["command"]}'
        elif event.name == 'CommandOutput':
            text = event.args['output']
            if event.args['pipe'] == 'stderr':
                text_style += Fore.RED
        elif event.name == 'CommandFailed':
            text = f'Command failed with exit code {event.args["code"]}'
            if event.args['description']:
                text += f'{Style.NORMAL}\n{self.indent(event.args["description"], 3)}'
        elif event.name == 'InvalidMofile':
            text = f'Invalid task file: {Style.NORMAL}{event.args["filename"]}'
        elif event.name == 'UndefinedVariable':
            text = f'Undefined variable: {Style.NORMAL}{event.args["variable"]}'
        elif event.name == 'TaskNotFound':
            text = f'No such task: {Style.NORMAL}{event.args["name"]}'
            if event.args['similarities']:
                similarities_str = ', '.join(event.args['similarities'])
                text += f' Did you mean? {similarities_str}'
        elif event.name == 'HelpOutput':
            print()
            for line in event.args['output'].splitlines():
                print('', line)
            return
        elif event.name == 'Help':
            print('Available tasks:')
            print()
            for name, task in event.args['tasks'].items():
                print(name, '-', task.description)
            return
        else:
            character = '?'
            character_style = Fore.YELLOW
            text = f'Unknown event: {Style.NORMAL}{event}'
            text_style = Fore.YELLOW

        character_style += Style.BRIGHT

        print(
            f' {character_style}{character}{Style.RESET_ALL}' +
            f' {text_style}{text}{Style.RESET_ALL}'
        )