本文整理匯總了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
示例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)
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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()
示例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)
示例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("")
示例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('	', "\t")
return color + line + Style.RESET_ALL
示例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()
示例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="")