Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sf = Style.RESET_ALL
else:
init(autoreset=True)
# colors foreground text:
fc = Fore.CYAN
fg = Fore.GREEN
fw = Fore.WHITE
fr = Fore.RED
fb = Fore.BLUE
fy = Fore.YELLOW
fm = Fore.MAGENTA
ff = Fore.RESET
# colors background text:
bc = Back.CYAN
bg = Back.GREEN
bw = Back.WHITE
br = Back.RED
bb = Back.BLUE
by = Back.YELLOW
bm = Back.MAGENTA
bf = Back.RESET
# colors style text:
sd = Style.DIM
sn = Style.NORMAL
sb = Style.BRIGHT
sf = Style.RESET_ALL
fgb = fg + sb
fbb = fb + sb
#!/usr/bin/python
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
# Simple demo of changing foreground, background and brightness.
from __future__ import print_function
import fixpath
from colorama import init, Fore, Back, Style
init()
print(Fore.GREEN + 'green, '
+ Fore.RED + 'red, '
+ Fore.RESET + 'normal, '
, end='')
print(Back.GREEN + 'green, '
+ Back.RED + 'red, '
+ Back.RESET + 'normal, '
, end='')
print(Style.DIM + 'dim, '
+ Style.BRIGHT + 'bright, '
+ Style.NORMAL + 'normal'
, end=' ')
print()
def getItem(item):
if item == Board.BLACK :
return Fore.WHITE + "|" + Fore.BLACK + "O"
elif item == Board.WHITE :
return Fore.WHITE + "|" + Fore.WHITE + "O"
else:
return Fore.WHITE + "| "
def getRow(row):
return "".join(map(getItem,row))
print("\t" + Back.GREEN + " BOARD ")
print("\t" + Back.GREEN + Fore.WHITE + " |0|1|2|3|4|5|6|7")
for i in range(8):
print("\t" + Back.GREEN + Fore.WHITE + "{}{}".format(i,
getRow(self.board[i])))
sys.stdout.write(Style.RESET_ALL)
owner = response_dict.get("as_owner")
country = response_dict.get("country")
# Calculations -------------------------------------------------------------------------------------
# Rating
# Calculate ratio
if positives > 0 and total > 0:
ratio = (float(positives) / float(total)) * 100
# Set rating
if ratio > 3 and rating == "clean":
rating = "suspicious"
if ratio > 10 and (rating == "clean" or rating == "suspicious"):
rating = "malicious"
# Type
res_color = Back.GREEN
if rating == "suspicious":
res_color = Back.YELLOW
if rating == "malicious":
res_color = Back.RED
# Result -------------------------------------------------------------------------------------------
result = "%s / %s" % ( positives, total )
print_highlighted("COUNTRY: {0} OWNER: {1}".format(country, owner))
print_highlighted("POSITIVES: %s RATING: %s" % (result, rating), hl_color=res_color)
else:
# Print the highlighted result line
print_highlighted("POSITIVES: %s RATING: %s" % (result, rating), hl_color=res_color)
# CSV OUTPUT -------------------------------------------------------------------------------------------
# Add to log file
self.COLORS = {
'none' : "",
'default' : Style.RESET_ALL,
'black' : Fore.BLACK,
'red' : Fore.RED,
'green' : Fore.GREEN,
'yellow' : Fore.YELLOW,
'blue' : Fore.BLUE,
'magenta' : Fore.MAGENTA,
'cyan' : Fore.CYAN,
'white' : Fore.WHITE,
'on_black' : Back.BLACK,
'on_red' : Back.RED,
'on_green' : Back.GREEN,
'on_yellow' : Back.YELLOW,
'on_blue' : Back.BLUE,
'on_magenta' : Back.MAGENTA,
'on_cyan' : Back.CYAN,
'on_white' : Back.WHITE,
}
def __init__(self, width=None, padding=1, fill_symbol=' ', header_background=Back.GREEN):
self._terminal_width = width or self._get_terminal_size()
self._header_background = header_background
self._padding = padding
self._fill_symbol = fill_symbol
self._table = []