-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathprinter.py
66 lines (47 loc) · 1.56 KB
/
printer.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
class Printer:
UI_CLI = 0
UI_CONSOLE = 1
INFOBLUE = '\033[96m'
OKGREEN = '\033[92m'
DEBUG = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
def __init__(self,uitype=0,textcontrol=None):
self.set_uitype(uitype)
def set_uitype(self,uitype):
if uitype == Printer.UI_CLI:
self.printer = CliPrinter()
elif uitype == Printer.UI_CONSOLE:
self.printer = ConsolePrinter()
else:
self.printer = CliPrinter()
def print_err(self,text):
self.printer.print_err(text)
def print_ok(self,text):
self.printer.print_ok(text)
def print_info(self,text):
self.printer.print_info(text)
def print_debug(self,text):
self.printer.print_debug(text)
class CliPrinter(Printer):
def __init__(self):
return
def print_err(self,text):
print(text)
def print_ok(self,text):
print(text)
def print_info(self,text):
print (text)
def print_debug(self,text):
print (text)
class ConsolePrinter(Printer):
def __init__(self):
return
def print_err(self,text):
print self.FAIL+ "[ ERROR ]: "+text+self.ENDC
def print_ok(self,text):
print self.OKGREEN+ "[ OK ]: "+text+self.ENDC
def print_info(self,text):
print self.INFOBLUE+"[ INFO ]: "+text+self.ENDC
def print_debug(self,text):
print self.DEBUG+ "[ DEBUG ]: "+text+self.ENDC