-
Notifications
You must be signed in to change notification settings - Fork 3
/
utils.py
51 lines (27 loc) · 925 Bytes
/
utils.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
import colorama
import pprint
def createPrettyPrinter(stream=None):
return pprint.PrettyPrinter(indent=0, width=60, stream=stream)
def backColorStr(s, color):
return f"{color}{s}{colorama.Back.RESET}"
def foreColorStr(s, color):
return f"{color}{s}{colorama.Fore.RESET}"
def grayBackStr(s):
return backColorStr(s, colorama.Back.LIGHTMAGENTA_EX)
def whiteBackStr(s):
return foreColorStr(backColorStr(s, colorama.Back.WHITE), colorama.Fore.BLACK)
def yellowStr(s):
return foreColorStr(s, colorama.Fore.YELLOW)
def blueBackStr(s):
return backColorStr(s, colorama.Back.BLUE)
def greenBackStr(s):
return backColorStr(s, colorama.Back.GREEN)
def redBackStr(s):
return backColorStr(s, colorama.Back.RED)
def logError(s):
print(redBackStr(s))
def lenInBytes(string):
return len(string.encode("utf-8"))
def writeText(file, str):
file.write(str)
file.flush()