当前位置: 首页>>代码示例>>Python>>正文


Python Fore.BLACK属性代码示例

本文整理汇总了Python中colorama.Fore.BLACK属性的典型用法代码示例。如果您正苦于以下问题:Python Fore.BLACK属性的具体用法?Python Fore.BLACK怎么用?Python Fore.BLACK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在colorama.Fore的用法示例。


在下文中一共展示了Fore.BLACK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_highlighted

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    try:
        # Highlight positives
        colorer = re.compile(r'([^\s]+) POSITIVES: ([1-9]) ')
        line = colorer.sub(Fore.YELLOW + r'\1 ' + 'POSITIVES: ' + Fore.YELLOW + r'\2 ' + Style.RESET_ALL, line)
        colorer = re.compile(r'([^\s]+) POSITIVES: ([0-9]+) ')
        line = colorer.sub(Fore.RED + r'\1 ' + 'POSITIVES: ' + Fore.RED + r'\2 ' + Style.RESET_ALL, line)
        # Keyword highlight
        colorer = re.compile(r'([A-Z_]{2,}:)\s', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
        print(line)
    except Exception as e:
        pass 
开发者ID:Neo23x0,项目名称:munin,代码行数:18,代码来源:munin-host.py

示例2: printHighlighted

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def printHighlighted(line, hl_color=Back.WHITE, tag_color=False):
    """
    Print a highlighted line
    """
    if tag_color:
        # Tags
        colorer = re.compile('(HARMLESS|SIGNED|MS_SOFTWARE_CATALOGUE|MSSOFT|SUCCESSFULLY\sCOMMENTED)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.GREEN + r'\1' + Style.RESET_ALL + '', line)
        colorer = re.compile('(REVOKED|EXPLOIT|CVE-[0-9\-]+|OBFUSCATED|RUN\-FILE)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.RED + r'\1' + Style.RESET_ALL + '', line)
        colorer = re.compile('(EXPIRED|VIA\-TOR|OLE\-EMBEDDED|RTF|ATTACHMENT|ASPACK|UPX|AUTO\-OPEN|MACROS)', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + Back.YELLOW + r'\1' + Style.RESET_ALL + '', line)
    # Extras
    colorer = re.compile('(\[!\])', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.LIGHTMAGENTA_EX + r'\1' + Style.RESET_ALL + '', line)
    # Add line breaks
    colorer = re.compile('(ORIGNAME:)', re.VERBOSE)
    line = colorer.sub(r'\n\1', line)
    # Standard
    colorer = re.compile('([A-Z_]{2,}:)\s', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
    print(line) 
开发者ID:Neo23x0,项目名称:munin,代码行数:24,代码来源:munin_stdout.py

示例3: print_highlighted

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    # Tags
    colorer = re.compile('(HARMLESS|SIGNED|MS_SOFTWARE_CATALOGUE)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.GREEN + r'\1' + Style.RESET_ALL + ' ', line)
    colorer = re.compile('(SIG_REVOKED)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.RED + r'\1' + Style.RESET_ALL + ' ', line)
    colorer = re.compile('(SIG_EXPIRED)', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.YELLOW + r'\1' + Style.RESET_ALL + ' ', line)
    # Extras
    colorer = re.compile('(\[!\])', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + Back.CYAN + r'\1' + Style.RESET_ALL + ' ', line)
    # Standard
    colorer = re.compile('([A-Z_]{2,}:)\s', re.VERBOSE)
    line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
    print line 
开发者ID:Neo23x0,项目名称:Loki,代码行数:20,代码来源:vt-checker.py

示例4: print_highlighted

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def print_highlighted(line, hl_color=Back.WHITE):
    """
    Print a highlighted line
    """
    try:
        # Highlight positives
        colorer = re.compile(r'([^\s]+) POSITIVES: ([1-9]) ')
        line = colorer.sub(Fore.YELLOW + r'\1 ' + 'POSITIVES: ' + Fore.YELLOW + r'\2 ' + Style.RESET_ALL, line)
        colorer = re.compile(r'([^\s]+) POSITIVES: ([0-9]+) ')
        line = colorer.sub(Fore.RED + r'\1 ' + 'POSITIVES: ' + Fore.RED + r'\2 ' + Style.RESET_ALL, line)
        # Keyword highlight
        colorer = re.compile(r'([A-Z_]{2,}:)\s', re.VERBOSE)
        line = colorer.sub(Fore.BLACK + hl_color + r'\1' + Style.RESET_ALL + ' ', line)
        print line
    except Exception, e:
        pass 
开发者ID:Neo23x0,项目名称:Loki,代码行数:18,代码来源:vt-checker-hosts.py

示例5: color

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def color(s, c, style="bright"):
    color_map = {
        "black": Fore.BLACK,
        "red": Fore.RED,
        "green": Fore.GREEN,
        "yellow": Fore.YELLOW,
        "blue": Fore.BLUE,
        "magenta": Fore.MAGENTA,
        "cyan": Fore.CYAN,
        "white": Fore.WHITE,
    }
    style_map = {
        "dim": Style.DIM,
        "normal": Style.NORMAL,
        "bright": Style.BRIGHT,
    }

    return color_map[c] + style_map[style] + s + Style.RESET_ALL 
开发者ID:vinayak-mehta,项目名称:nbcommands,代码行数:20,代码来源:_grep.py

示例6: default_prefix_template

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def default_prefix_template(self, record):
        """Return the prefix for the log message. Template for Formatter.

        :param: record: :py:class:`logging.LogRecord` object. this is passed in
        from inside the :py:meth:`logging.Formatter.format` record.

        """
        reset = [Style.RESET_ALL]
        levelname = [
            LEVEL_COLORS.get(record.levelname), Style.BRIGHT,
            '%(levelname)-10s',
            Style.RESET_ALL, ' '
        ]
        asctime = [
            '', Fore.BLACK, Style.DIM, Style.BRIGHT,
            '%(asctime)-10s',
            Fore.RESET, Style.RESET_ALL, ' '
        ]

        return "".join(reset + asctime + levelname + reset) 
开发者ID:grap,项目名称:odoo-module-migrator,代码行数:22,代码来源:log.py

示例7: default_log_template

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def default_log_template(self, record):
    """Return the prefix for the log message. Template for Formatter.

    :param: record: :py:class:`logging.LogRecord` object. this is passed in
    from inside the :py:meth:`logging.Formatter.format` record.

    """

    reset = [Style.RESET_ALL]
    levelname = [
        LEVEL_COLORS.get(record.levelname), Style.BRIGHT,
        '(%(levelname)s)',
        Style.RESET_ALL, ' '
    ]
    asctime = [
        '[', Fore.BLACK, Style.DIM, Style.BRIGHT,
        '%(asctime)s',
        Fore.RESET, Style.RESET_ALL, ']'
    ]
    name = [
        ' ', Fore.WHITE, Style.DIM, Style.BRIGHT,
        '%(name)s',
        Fore.RESET, Style.RESET_ALL, ' '
    ]
    threadName = [
        ' ', Fore.BLUE, Style.DIM, Style.BRIGHT,
        '%(threadName)s ',
        Fore.RESET, Style.RESET_ALL, ' '
    ]

    tpl = "".join(reset + levelname + asctime + name + threadName + reset)

    return tpl 
开发者ID:acsone,项目名称:git-aggregator,代码行数:35,代码来源:log.py

示例8: live_score

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def live_score(self, index):
        if self.all_match_data[index]['mchstate'] == 'preview':
            return(Fore.RED + "MATCH YET TO BEGIN")
        selected_match = self.all_match_data[index]
        data = self.c.livescore(self.matches[index]['id'])
        score = {}
        score['matchinfo'] = "{}, {}".format(
            selected_match['srs'], selected_match['mnum'])
        score['status'] = "{}".format(selected_match['status'])
        score['bowling'] = data['bowling']
        score['batting'] = data['batting']

        text = ''
        text += Fore.LIGHTYELLOW_EX + \
            score['matchinfo'] + '\n' + score['status'] + '\n\n'

        text += Fore.BLUE + score['batting']['team'] + Fore.BLACK
        for scr in reversed(score['batting']['score']):
            text += " :- {}/{} in {} overs\n".format(
                scr['runs'], scr['wickets'], scr['overs'])
        for b in reversed(score['batting']['batsman']):
            text += "{} : {}({}) \n".format(
                b['name'].strip('*'), b['runs'], b['balls'])

        text += Fore.BLUE + '\n' + score['bowling']['team'] + Fore.BLACK
        for scr in reversed(score['bowling']['score']):
            text += " :- {}/{} in {} overs\n".format(
                scr['runs'], scr['wickets'], scr['overs'])
        for b in reversed(score['bowling']['bowler']):
            text += "{} : {}/{} \n".format(b['name'].strip('*'),
                                           b['wickets'], b['runs'])
        text += Fore.RESET

        return text 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:36,代码来源:cricket.py

示例9: scorecard

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def scorecard(self, index):
        selected_match = self.all_match_data[index]
        data = self.c.scorecard(self.matches[index]['id'])
        card = {}
        card['matchinfo'] = "{}, {}".format(
            selected_match['srs'], selected_match['mnum'])
        card['status'] = "{}".format(selected_match['status'])
        card['scorecard'] = data['scorecard']
        text = ''
        text += Fore.LIGHTYELLOW_EX + \
            card['matchinfo'] + '\n' + card['status'] + '\n\n'
        text += Fore.BLACK + '*' * 35 + '\n\n'

        for scr in reversed(card['scorecard']):
            text += Fore.LIGHTYELLOW_EX + "{}\nInnings: {}\n{}/{} in {} overs\n\n".format(
                scr['batteam'], scr['inng_num'], scr['runs'], scr['wickets'], scr['overs'])
            text += Fore.BLUE + "Batting\n"
            text += Fore.RED + \
                "{:<17} {:<3} {:<3} {:<3} {}\n\n".format('Name', 'R', 'B', '4', '6')
            for b in scr['batcard']:
                text += Fore.BLACK + "{:<17} {:<3} {:<3} {:<3} {}\n{}\n\n".format(
                    b['name'], b['runs'], b['balls'], b['fours'], b['six'], b['dismissal'])
            text += Fore.LIGHTYELLOW_EX + "-" * 35 + "\n\n"
            text += Fore.BLUE + "Bowling\n"
            text += Fore.RED + \
                "{:<17} {:<5} {:<3} {:<3} {}\n\n".format('Name', 'O', 'M', 'R', 'W')
            for b in scr['bowlcard']:
                text += Fore.BLACK + "{:<17} {:<5} {:<3} {:<3} {}\n\n".format(
                    b['name'], b['overs'], b['maidens'], b['runs'], b['wickets'])
            text += Fore.BLUE + '*' * 35 + '\n\n'
        return text 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:33,代码来源:cricket.py

示例10: __call__

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def __call__(self, jarvis, s):
        prompt = "{black}Q{Q_id} {cyan}{left} {black}--- {green}{right}"
        prompt_formatter = {
            'cyan': Fore.CYAN,
            'black': Fore.BLACK,
            'green': Fore.GREEN
        }
        jarvis.say("Start personality test..", color=Fore.BLACK)
        jarvis.say(self.instruction)
        for i, (Q_id, left, right) in enumerate(self.Q):
            prompt_formatter['Q_id'] = i
            prompt_formatter['left'] = left
            prompt_formatter['right'] = right

            jarvis.say(prompt.format(**prompt_formatter))
            user_input = jarvis.input_number(
                prompt="Enter your choice on the scale of 1-5:\n", rmin=1,
                rmax=5, color=Fore.BLUE, rtype=int)
            self.answers[Q_id] = user_input
        self.get_scores()

        jarvis.say(
            "{}Your personality is: {}{}{}{}".format(
                Fore.BLUE,
                Fore.BLACK,
                Back.MAGENTA,
                self.type,
                Style.RESET_ALL))
        jarvis.say(
            "Redirecting to your personality analysis\
                 in 3s...", color=Fore.BLUE)
        time.sleep(3)
        self.open_analysis() 
开发者ID:sukeesh,项目名称:Jarvis,代码行数:35,代码来源:personality.py

示例11: printSeparator

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def printSeparator(count, total, color, rating):
    """
    Print a separator line status infos
    :param count:
    :param total:
    :return:
    """
    print(Fore.BLACK + color)
    print(" {0} / {1} > {2}".format(count+1, total, rating.title()).ljust(80) + Style.RESET_ALL) 
开发者ID:Neo23x0,项目名称:munin,代码行数:11,代码来源:munin_stdout.py

示例12: printKeyLine

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def printKeyLine(line):
    """
    Print a given string as a separator line
    :param line:
    :return:
    """
    print(Fore.BLACK + Back.WHITE)
    print("{0}".format(line).ljust(80) + Style.RESET_ALL)
    print("") 
开发者ID:Neo23x0,项目名称:munin,代码行数:11,代码来源:munin_stdout.py

示例13: parseLine

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
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 
开发者ID:screepers,项目名称:screeps_console,代码行数:28,代码来源:outputparser.py

示例14: execute_command

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def execute_command(self):
        """
        The web command runs the Scrapple web interface through a simple \
        `Flask <http://flask.pocoo.org>`_ app. 

        When the execute_command() method is called from the \
        :ref:`runCLI() <implementation-cli>` function, it starts of two simultaneous \
        processes : 

        - Calls the run_flask() method to start the Flask app on port 5000 of localhost
        - Opens the web interface on a web browser

        The '/' view of the Flask app, opens up the Scrapple web interface. This \
        provides a basic form, to fill in the required configuration file. On submitting \
        the form, it makes a POST request, passing in the form in the request header. \
        This form is passed to the form_to_json() \
        :ref:`utility function <implementation-utils>`, where the form is converted into \
        the resultant JSON configuration file.

        Currently, closing the web command execution requires making a keyboard interrupt \
        on the command line after the web interface has been closed.

        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Web Interface")
        print(Back.RESET + Fore.RESET)
        p1 = Process(target = self.run_flask)
        p2 = Process(target = lambda : webbrowser.open('http://127.0.0.1:5000'))
        p1.start()
        p2.start() 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:31,代码来源:web.py

示例15: execute_command

# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLACK [as 别名]
def execute_command(self):
        """
        The generate command uses `Jinja2 <http://jinja.pocoo.org/>`_ templates \
        to create Python scripts, according to the specification in the configuration \
        file. The predefined templates use the extract_content() method of the \
        :ref:`selector classes <implementation-selectors>` to implement linear extractors \
        and use recursive for loops to implement multiple levels of link crawlers. This \
        implementation is effectively a representation of the traverse_next() \
        :ref:`utility function <implementation-utils>`, using the loop depth to \
        differentiate between levels of the crawler execution. 

        According to the --output_type argument in the CLI input, the results are \
        written into a JSON document or a CSV document. 

        The Python script is written into <output_filename>.py - running this file \
        is the equivalent of using the Scrapple :ref:`run command <command-run>`. 

        """
        print(Back.GREEN + Fore.BLACK + "Scrapple Generate")
        print(Back.RESET + Fore.RESET)
        directory = os.path.join(scrapple.__path__[0], 'templates', 'scripts')
        with open(os.path.join(directory, 'generate.txt'), 'r') as f:
            template_content = f.read()
        template = Template(template_content)
        try:
            with open(self.args['<projectname>'] + '.json', 'r') as f:
                config = json.load(f)
            if self.args['--output_type'] == 'csv':
                from scrapple.utils.config import extract_fieldnames
                config['fields'] = str(extract_fieldnames(config))
            config['output_file'] = self.args['<output_filename>']
            config['output_type'] = self.args['--output_type']
            rendered = template.render(config=config)
            with open(self.args['<output_filename>'] + '.py', 'w') as f:
                f.write(rendered)
            print(Back.WHITE + Fore.RED + self.args['<output_filename>'], \
                  ".py has been created" + Back.RESET + Fore.RESET, sep="")
        except IOError:
            print(Back.WHITE + Fore.RED + self.args['<projectname>'], ".json does not ", \
                  "exist. Use ``scrapple genconfig``." + Back.RESET + Fore.RESET, sep="") 
开发者ID:AlexMathew,项目名称:scrapple,代码行数:42,代码来源:generate.py


注:本文中的colorama.Fore.BLACK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。