forked from ddaln/rtx_hackathon_2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbcolors.py
80 lines (72 loc) · 2.34 KB
/
bcolors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'''
SOURCE: https://gist.github.com/tuvokki/14deb97bef6df9bc6553
'''
# Helper class to print colored output
#
# To use code like this, you can do something like
#
# print bcolors.WARNING
# + "Warning: No active frommets remain. Continue?"
# + bcolors.ENDC
#
# you can also use the convenience method bcolors.colored like this
#
# print(bcolors.colored("This frumble is underlined", bcolors.UNDERLINE))
#
# or use one of the following convenience methods
# warning, fail, ok, okblue, header
#
# like this
#
# print(bcolors.warning("This is dangerous"))
#
# Method calls can be nested too, pritn an underlined header do this:
#
# print(bcolors.header(bcolors.colored("The line under this text is purple too ... ", bcolors.UNDERLINE)))
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ENDC = '\033[0m'
# Method that returns a message with the desired color
# usage:
# print(bcolor.colored("My colored message", bcolor.OKBLUE))
@staticmethod
def colored(message, color):
return color + message + bcolors.ENDC
# Method that returns a yellow warning
# usage:
# print(bcolors.warning("What you are about to do is potentially dangerous. Continue?"))
@staticmethod
def warning(message):
return bcolors.WARNING + message + bcolors.ENDC
# Method that returns a red fail
# usage:
# print(bcolors.fail("What you did just failed massively. Bummer"))
# or:
# sys.exit(bcolors.fail("Not a valid date"))
@staticmethod
def fail(message):
return bcolors.FAIL + message + bcolors.ENDC
# Method that returns a green ok
# usage:
# print(bcolors.ok("What you did just ok-ed massively. Yay!"))
@staticmethod
def ok(message):
return bcolors.OKGREEN + message + bcolors.ENDC
# Method that returns a blue ok
# usage:
# print(bcolors.okblue("What you did just ok-ed into the blue. Wow!"))
@staticmethod
def okblue(message):
return bcolors.OKBLUE + message + bcolors.ENDC
# Method that returns a header in some purple-ish color
# usage:
# print(bcolors.header("This is great"))
@staticmethod
def header(message):
return bcolors.HEADER + message + bcolors.ENDC