forked from cybersecurity-team/TorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.py
More file actions
46 lines (40 loc) · 1.23 KB
/
Copy pathcolor.py
File metadata and controls
46 lines (40 loc) · 1.23 KB
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
"""
Module containing class with colors
"""
COLORS = {
'white': "\033[1;37m",
'yellow': "\033[1;33m",
'green': "\033[1;32m",
'blue': "\033[1;34m",
'cyan': "\033[1;36m",
'red': "\033[1;31m",
'magenta': "\033[1;35m",
'black': "\033[1;30m",
'darkwhite': "\033[0;37m",
'darkyellow': "\033[0;33m",
'darkgreen': "\033[0;32m",
'darkblue': "\033[0;34m",
'darkcyan': "\033[0;36m",
'darkred': "\033[0;31m",
'darkmagenta': "\033[0;35m",
'darkblack': "\033[0;30m",
'end': "\033[0;0m"
}
class color:
"""
Class that contains colors used for TorBot in terminal and a method
that adds color to a string.
Attributes:
message (string): Message to be wrapped in color.
selected (string): Color to be displayed.
"""
def __init__(self, message, selected):
"""Initialise color object with specified text and selected color."""
self._msg = message
self._color = COLORS[selected]
def __str__(self):
return self._color + self._msg + COLORS['end']
def __add__(self, other):
return str(self) + other
def __radd__(self, other):
return other + str(self)