-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyUtls.py
More file actions
210 lines (172 loc) Β· 5.82 KB
/
PyUtls.py
File metadata and controls
210 lines (172 loc) Β· 5.82 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import os
from datetime import datetime
from typing import Optional
import platform
import shutil
from time import sleep as wait
import threading as thr
platform = platform.platform().split("-")[0]
columns = shutil.get_terminal_size().columns
lines = int(round(shutil.get_terminal_size().lines/2, 0))
os.system('')
now = datetime.now()
threads = []
class colors:
CEND = '\33[0m'
CBOLD = '\33[1m'
CITALIC = '\33[3m'
CURL = '\33[4m'
CBLINK = '\33[5m'
CBLINK2 = '\33[6m'
CSELECTED = '\33[7m'
CBLACK = '\33[30m'
CRED = '\33[31m'
CGREEN = '\33[32m'
CYELLOW = '\33[33m'
CBLUE = '\33[34m'
CVIOLET = '\33[35m'
CBEIGE = '\33[36m'
CWHITE = '\33[37m'
CBLACKBG = '\33[40m'
CREDBG = '\33[41m'
CGREENBG = '\33[42m'
CYELLOWBG = '\33[43m'
CBLUEBG = '\33[44m'
CVIOLETBG = '\33[45m'
CBEIGEBG = '\33[46m'
CWHITEBG = '\33[47m'
CGREY = '\33[90m'
CRED2 = '\33[91m'
CGREEN2 = '\33[92m'
CYELLOW2 = '\33[93m'
CBLUE2 = '\33[94m'
CVIOLET2 = '\33[95m'
CBEIGE2 = '\33[96m'
CWHITE2 = '\33[97m'
CGREYBG = '\33[100m'
CREDBG2 = '\33[101m'
CGREENBG2 = '\33[102m'
CYELLOWBG2 = '\33[103m'
CBLUEBG2 = '\33[104m'
CVIOLETBG2 = '\33[105m'
CBEIGEBG2 = '\33[106m'
CWHITEBG2 = '\33[107m'
class projectDetails:
owner = ''
projectName = ''
version = ''
class settings:
printCap = True
timeColor = colors.CVIOLET2
logo = ''
logoColor = colors.CWHITE2
logoOnClear = False
centerLogo = False
startanimadelay = .1
startmsg = ''
logoAnim = True
logoAnimDelay = .01
def current_time():
return f'{colors.CGREY}[{colors.CEND}{settings.timeColor}{now.strftime("%H:%M:%S")}{colors.CEND}{colors.CGREY}]{colors.CEND}'
def logo():
if settings.logoAnim == True:
if settings.centerLogo:
for line in settings.logo.split('\n'):
wait(settings.logoAnimDelay)
print(settings.logoColor+line.center(columns)+colors.CEND)
else:
wait(settings.logoAnimDelay)
print(settings.logoColor+settings.logo+colors.CEND)
else:
if settings.centerLogo:
for line in settings.logo.split('\n'):
print(settings.logoColor+line.center(columns)+colors.CEND)
else:
print(settings.logoColor+settings.logo+colors.CEND)
def animLogo(delay:int):
if settings.centerLogo:
for line in settings.logo.split('\n'):
wait(delay)
print(settings.logoColor+line.center(columns)+colors.CEND)
else:
wait(delay)
print(settings.logoColor+settings.logo+colors.CEND)
def startUp(waitForDone:bool):
def main():
for i in range(lines):
print()
wait(settings.startanimadelay)
print(colors.CWHITE2+settings.startmsg.center(columns)+colors.CEND+'\n')
for line in settings.logo.split('\n'):
wait(settings.startanimadelay)
print(settings.logoColor+line.center(columns)+colors.CEND)
print(f'{colors.CWHITE2}{projectDetails.projectName} - Made by: {projectDetails.owner}'.center(columns))
wait(settings.startanimadelay)
print(f'v{projectDetails.version}{colors.CEND}'.center(columns))
for i in range(lines):
print()
wait(settings.startanimadelay)
wait(1)
clear()
if waitForDone == True:
startUpThr = thr.Thread(target=main)
startUpThr.name = 'startup'
threads.append(startUpThr)
startUpThr.start()
startUpThr.join()
else:
startUpThr = thr.Thread(target=main)
startUpThr.name = 'startup'
threads.append(startUpThr)
startUpThr.start()
def waitForStartup():
for i in threads:
if i.name == 'startup':
i.join()
def error(why):
waitForStartup()
print(f'{current_time()} {colors.CBOLD+colors.CREDBG2}ERROR{colors.CEND+colors.CWHITE}: {colors.CBOLD+colors.CRED2+str(why)}{colors.CEND}')
def warn(why, solve: Optional = None) -> None:
waitForStartup()
if not solve:
print(f'{current_time()} {colors.CBOLD+colors.CYELLOWBG}WARNING{colors.CEND+colors.CWHITE}: {colors.CBOLD+colors.CYELLOW2+why+colors.CEND}')
else:
print(f'{current_time()} {colors.CBOLD+colors.CYELLOWBG}WARNING{colors.CEND+colors.CWHITE}: {colors.CBOLD+colors.CYELLOW2+str(why)+colors.CEND} - {colors.CITALIC+colors.CYELLOW+str(solve)+colors.CEND}')
def success(message):
waitForStartup()
print(f'{current_time()} {colors.CBOLD+colors.CGREENBG}SUCCESS{colors.CEND+colors.CWHITE}: {colors.CBOLD+colors.CGREEN+str(message)+colors.CEND}')
def fail(message):
waitForStartup()
print(f'{current_time()} {colors.CBOLD+colors.CREDBG}FAIL{colors.CEND+colors.CWHITE}: {colors.CBOLD+colors.CRED2+str(message)+colors.CEND}')
def binput(ask):
waitForStartup()
return input(f'{current_time()} {colors.CWHITE+ask+colors.CEND}')
def bprint(message: Optional = None) -> None:
waitForStartup()
if message:
if settings.printCap:
print(f'{current_time()} {colors.CBOLD+colors.CWHITE+str(message).capitalize()}')
else:
print(f'{current_time()} {colors.CBOLD+colors.CWHITE+message}')
else:
print()
def clear():
if platform == "Windows":
import os
os.system("cls")
if settings.logoOnClear:
logo()
elif platform == "Linux":
try:
import os
os.system("clear")
if settings.logoOnClear:
logo()
except:
import replit
replit.clear()
if settings.logoOnClear:
logo()
# def makeMenu(**opts):
# for opt,do in opts.items():
# print(f'This {opt} has to do {do}')