-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorMessage.py
38 lines (30 loc) · 1.35 KB
/
colorMessage.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
class ColorMessage:
def __init__(self):
self.__colorDict = {
"red": "\u001b[31m",
"green": "\u001b[32m",
"blue": "\u001b[34m",
"yellow": "\u001b[33m",
"reset": "\u001b[0m"
}
def __resetColor(self):
print(self.__colorDict["reset"], end="")
def printColor(self, value, color = "", inicio = "", fin = "\n"):
if self.__colorDict.get(color) != None:
print(f"{self.__colorDict.get(color)}{inicio}{value}", end = fin)
else:
print(f"{inicio}{value}", end = fin)
self.__resetColor()
class PrintService:
def __init__(self):
self.colorMsg = ColorMessage()
def mensaje(self, mensaje, inicio = "", fin = "\n"):
print(f"{inicio}{mensaje}", end = fin)
def mensajeImportante(self, mensaje, inicio = "", fin = "\n"):
self.colorMsg.printColor(f"{mensaje}", "blue", inicio, fin)
def mensajeError(self, mensaje, inicio = "", fin = "\n"):
self.colorMsg.printColor(f"=> ERROR: {mensaje}", "red", inicio, fin)
def mensajeExito(self, mensaje, inicio = "", fin = "\n"):
self.colorMsg.printColor(f"=> EXITO: {mensaje}", "green", inicio, fin)
def mensajeAdvertencia(self, mensaje, inicio = "", fin = "\n"):
self.colorMsg.printColor(f"=> ADVERTENCIA: {mensaje}", "yellow", inicio, fin)