-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.py
69 lines (49 loc) · 1.16 KB
/
colors.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
"""module for printing colors to terminal"""
# copied from David Barnes colors.py file
# System Imports
import os
# First Party Imports
# Third Party Imports
os.system("")
def singleton(cls):
"""Singleton functioin"""
return cls()
@singleton
class Style:
"""Contains color constants"""
BLACK = "\033[30m"
RED = "\033[31m"
GREEN = "\033[32m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"
UNDERLINE = "\033[4m"
RESET = "\033[0m"
CLEAR = "\033[H\033[2J"
def __getattribute__(self, name):
"""Override default dunder method"""
value = super().__getattribute__(name)
print(value, end="")
return value
def print_red(message):
"""method to print in red"""
Style.RED
print(message)
Style.RESET
def print_green(message):
"""method to print green"""
Style.GREEN
print(message)
Style.RESET
def print_blue(message):
"""method to print blue"""
Style.BLUE
print(message)
Style.RESET
def print_yellow(message):
"""method to print yellow"""
Style.YELLOW
print(message)
Style.RESET