本文整理汇总了Python中colorama.Fore.BLUE属性的典型用法代码示例。如果您正苦于以下问题:Python Fore.BLUE属性的具体用法?Python Fore.BLUE怎么用?Python Fore.BLUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类colorama.Fore
的用法示例。
在下文中一共展示了Fore.BLUE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: walker
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def walker(node, source_lines, indent=''):
"""Recursively visit the ast in a preorder traversal."""
node_name = str(node)[0:str(node).index('(')]
value = None
if hasattr(node, 'value'):
if '(' in str(node.value):
value = str(node.value)[0:str(node.value).index('(')]
else:
value = node.value
name = node.name if hasattr(node, 'name') else None
print('{}{} {} (name: {}, value: {})'.format(
indent, CHAR_TUBE, node_name, name, value))
lines = [line for line in node.as_string().split('\n')]
for line in lines:
print(indent + FILL + '>>>' + Fore.BLUE + line + Fore.RESET)
for child in node.get_children():
walker(child, source_lines, indent + FILL + CHAR_PIPE)
示例2: _init_plugin_info
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def _init_plugin_info(self):
plugin_status_formatter = {
"disabled": len(self._plugin_manager.get_disabled()),
"enabled": self._plugin_manager.get_number_plugins_loaded(),
"red": Fore.RED,
"blue": Fore.BLUE,
"reset": Fore.RESET
}
plugin_status = "{red}{enabled} {blue}plugins loaded"
if plugin_status_formatter['disabled'] > 0:
plugin_status += " {red}{disabled} {blue}plugins disabled. More information: {red}status\n"
plugin_status += Fore.RESET
self.first_reaction_text += plugin_status.format(
**plugin_status_formatter)
示例3: workout
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def workout(jarvis, s):
"""Provides a workout programm according to user's abilities
Formula to generate a relevant program is taken from:
https://www.gbpersonaltraining.com/how-to-perform-100-push-ups/"""
s = jarvis.input(
"Choose an exercise. Write 'push' for pushups, 'pull' for pullups and 'q' for quit\n", Fore.GREEN)
if (s == "'q'" or s == "q"):
quit(jarvis)
elif (s == "'push'" or s == "push"):
s = jarvis.input(
"How many times can you push up? Please enter an integer!\n", Fore.GREEN)
pushups(jarvis, s)
elif (s == "'pull'" or s == "pull"):
s = jarvis.input(
"How many times can you pull up? Please enter an integer!\n", Fore.GREEN)
pullups(jarvis, s)
else:
jarvis.say(
"Incorrect input, please write either 'push' or 'pull'", Fore.BLUE)
quit(jarvis)
示例4: matches
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def matches(self, jarvis, compId):
"""
Fetches today's matches in given competition
and prints the match info
"""
print()
jarvis.spinner_start('Fetching ')
r = fetch("/matches?competitions={}".format(compId))
if r is None:
jarvis.spinner_stop("Error in fetching data - try again later.", Fore.YELLOW)
return
jarvis.spinner_stop('')
if r["count"] == 0:
jarvis.say("No matches found for today.", Fore.BLUE)
return
else:
# Print each match info
for match in r["matches"]:
matchInfo = self.formatMatchInfo(match)
length = len(matchInfo)
jarvis.say(matchInfo[0], Fore.BLUE)
for i in range(1, length):
print(matchInfo[i])
print()
示例5: temp_convert
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def temp_convert(self, jarvis, s):
"""Assuming valid regex, handle the actual temperature conversion and output"""
# convert the string into a float
starting_temp = float(s[:-1])
# run conversions and create output string.
if s[-1].lower() == 'f':
new_temp = self.convert_f_to_c(starting_temp)
output = "{}° F is {}° C".format(starting_temp, new_temp)
else:
new_temp = self.convert_c_to_f(starting_temp)
output = "{}° C is {}° F".format(starting_temp, new_temp)
# use print_say to display the output string
jarvis.say(output, Fore.BLUE)
示例6: check_ram__WINDOWS
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def check_ram__WINDOWS(jarvis, s):
"""
checks your system's RAM stats.
-- Examples:
check ram
"""
import psutil
mem = psutil.virtual_memory()
def format(size):
mb, _ = divmod(size, 1024 * 1024)
gb, mb = divmod(mb, 1024)
return "%s GB %s MB" % (gb, mb)
jarvis.say("Total RAM: %s" % (format(mem.total)), Fore.BLUE)
if mem.percent > 80:
color = Fore.RED
elif mem.percent > 60:
color = Fore.YELLOW
else:
color = Fore.GREEN
jarvis.say("Available RAM: %s" % (format(mem.available)), color)
jarvis.say("RAM used: %s%%" % (mem.percent), color)
示例7: calc
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def calc(jarvis, s, calculator=sympy.sympify, formatter=None, do_evalf=True):
s = format_expression(s)
try:
result = calculator(s)
except sympy.SympifyError:
jarvis.say("Error: Something is wrong with your expression", Fore.RED)
return
except NotImplementedError:
jarvis.say("Sorry, cannot solve", Fore.RED)
return
if formatter is not None:
result = formatter(result)
if do_evalf:
result = result.evalf()
jarvis.say(str(result), Fore.BLUE)
示例8: __show_diff
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def __show_diff(expected, actual):
seqm = difflib.SequenceMatcher(None, expected, actual)
output = [Style.RESET_ALL]
for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
if opcode == "equal":
output.append(seqm.a[a0:a1])
elif opcode == "insert":
output.append(Fore.GREEN + seqm.b[b0:b1] + Style.RESET_ALL)
elif opcode == "delete":
output.append(Fore.RED + seqm.a[a0:a1] + Style.RESET_ALL)
elif opcode == "replace":
output.append(Fore.BLUE + seqm.b[b0:b1] + Style.RESET_ALL)
else:
raise RuntimeError("unexpected opcode")
return "".join(output)
示例9: color_print
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def color_print(text, text_class):
colorama.init()
for c, n in zip(text, text_class):
if n == 1:
print(Fore.RED + c, end="")
elif n == 2:
print(Fore.GREEN + c, end="")
elif n == 3:
print(Fore.BLUE + c, end="")
elif n == 4:
print(Fore.YELLOW + c, end="")
else:
print(Fore.WHITE + c, end="")
print(Fore.RESET)
print()
示例10: default_log_template
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [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
示例11: debug
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def debug(*args, color=Fore.BLUE, sep=' ', end='\n', file=sys.stdout, **kvargs):
if verbose >= 2:
cprint(*args, color=color, char='-', sep=sep, end=end, file=file, frame_index=2, **kvargs)
示例12: parse_port_scan
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def parse_port_scan(stream, tag, target, pattern):
address = target.address
ports = []
while True:
line = await stream.readline()
if line:
line = str(line.rstrip(), 'utf8', 'ignore')
debug(Fore.BLUE + '[' + Style.BRIGHT + address + ' ' + tag + Style.NORMAL + '] ' + Fore.RESET + '{line}', color=Fore.BLUE)
parse_match = re.search(pattern, line)
if parse_match:
ports.append(parse_match.group('port'))
for p in global_patterns:
matches = re.findall(p['pattern'], line)
if 'description' in p:
for match in matches:
if verbose >= 1:
info('Task {bgreen}{tag}{rst} on {byellow}{address}{rst} - {bmagenta}' + p['description'].replace('{match}', '{bblue}{match}{crst}{bmagenta}') + '{rst}')
async with target.lock:
with open(os.path.join(target.scandir, '_patterns.log'), 'a') as file:
file.writelines(e('{tag} - ' + p['description'] + '\n\n'))
else:
for match in matches:
if verbose >= 1:
info('Task {bgreen}{tag}{rst} on {byellow}{address}{rst} - {bmagenta}Matched Pattern: {bblue}{match}{rst}')
async with target.lock:
with open(os.path.join(target.scandir, '_patterns.log'), 'a') as file:
file.writelines(e('{tag} - Matched Pattern: {match}\n\n'))
else:
break
return ports
示例13: parse_service_detection
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def parse_service_detection(stream, tag, target, pattern):
address = target.address
services = []
while True:
line = await stream.readline()
if line:
line = str(line.rstrip(), 'utf8', 'ignore')
debug(Fore.BLUE + '[' + Style.BRIGHT + address + ' ' + tag + Style.NORMAL + '] ' + Fore.RESET + '{line}', color=Fore.BLUE)
parse_match = re.search(pattern, line)
if parse_match:
services.append((parse_match.group('protocol').lower(), int(parse_match.group('port')), parse_match.group('service')))
for p in global_patterns:
matches = re.findall(p['pattern'], line)
if 'description' in p:
for match in matches:
if verbose >= 1:
info('Task {bgreen}{tag}{rst} on {byellow}{address}{rst} - {bmagenta}' + p['description'].replace('{match}', '{bblue}{match}{crst}{bmagenta}') + '{rst}')
async with target.lock:
with open(os.path.join(target.scandir, '_patterns.log'), 'a') as file:
file.writelines(e('{tag} - ' + p['description'] + '\n\n'))
else:
for match in matches:
if verbose >= 1:
info('Task {bgreen}{tag}{rst} on {byellow}{address}{rst} - {bmagenta}Matched Pattern: {bblue}{match}{rst}')
async with target.lock:
with open(os.path.join(target.scandir, '_patterns.log'), 'a') as file:
file.writelines(e('{tag} - Matched Pattern: {match}\n\n'))
else:
break
return services
示例14: color_diff_line
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def color_diff_line(line):
if line.startswith('+') and not line.startswith('+++'):
return Fore.GREEN + line + Fore.RESET
elif line.startswith('-') and not line.startswith('---'):
return Fore.RED + line + Fore.RESET
elif line.startswith('@@'):
return Fore.BLUE + line + Fore.RESET
else:
return line
示例15: locate_me
# 需要导入模块: from colorama import Fore [as 别名]
# 或者: from colorama.Fore import BLUE [as 别名]
def locate_me():
hcity = get_location()['city']
print(Fore.BLUE + "You are at " + hcity + Fore.RESET)