2024-11-19 13:47:45 +02:00
|
|
|
# AGPL 3 or any later version
|
|
|
|
# (C) J.Y.Amihud ( Blender Dumbass )
|
|
|
|
|
|
|
|
import random
|
|
|
|
|
|
|
|
clr = {
|
|
|
|
"norm":"\033[00m", # Reset to normal
|
|
|
|
"bold":"\033[01m", # Bold Text
|
|
|
|
"ital":"\033[03m", # Italic Text
|
|
|
|
"undr":"\033[04m", # Underlined
|
|
|
|
"blnk":"\033[05m", # Blinking
|
|
|
|
|
|
|
|
# Text
|
|
|
|
"tdbl":"\033[30m", # Dark Black
|
|
|
|
"tdrd":"\033[31m", # Dark Red
|
|
|
|
"tdgr":"\033[32m", # Dark Green
|
|
|
|
"tdyl":"\033[33m", # Dark Yellow
|
|
|
|
"tdbu":"\033[34m", # Dark Blue
|
|
|
|
"tdma":"\033[35m", # Dark Magenta
|
|
|
|
"tdcy":"\033[36m", # Dark Cyan
|
|
|
|
"tdwh":"\033[37m", # Dark White
|
|
|
|
|
|
|
|
"tbbl":"\033[90m", # Bright Black
|
|
|
|
"tbrd":"\033[91m", # Bright Red
|
|
|
|
"tbgr":"\033[92m", # Bright Green
|
|
|
|
"tbyl":"\033[93m", # Bright Yellow
|
|
|
|
"tbbu":"\033[94m", # Bright Blue
|
|
|
|
"tbma":"\033[95m", # Bright Magenta
|
|
|
|
"tbcy":"\033[96m", # Bright Cyan
|
|
|
|
"tbwh":"\033[97m", # Bright White
|
|
|
|
# Background
|
|
|
|
"bdbl":"\033[40m", # Dark Black
|
|
|
|
"bdrd":"\033[41m", # Dark Red
|
|
|
|
"bdgr":"\033[42m", # Dark Green
|
|
|
|
"bdyl":"\033[43m", # Dark Yellow
|
|
|
|
"bdbu":"\033[44m", # Dark Blue
|
|
|
|
"bdma":"\033[45m", # Dark Magenta
|
|
|
|
"bdcy":"\033[46m", # Dark Cyan
|
|
|
|
"bdwh":"\033[47m", # Dark White
|
|
|
|
|
|
|
|
"bbbl":"\033[100m", # Bright Black
|
|
|
|
"bbrd":"\033[101m", # Bright Red
|
|
|
|
"bbgr":"\033[102m", # Bright Green
|
|
|
|
"bbyl":"\033[103m", # Bright Yellow
|
|
|
|
"bbbu":"\033[104m", # Bright Blue
|
|
|
|
"bbma":"\033[105m", # Bright Magenta
|
|
|
|
"bbcy":"\033[106m", # Bright Cyan
|
|
|
|
"bbwh":"\033[108m" # Bright White
|
|
|
|
}
|
|
|
|
|
|
|
|
def Simplify(text):
|
|
|
|
|
|
|
|
good = "qwertyuiopasdfghjklzxcvbnm.1234567890-_:"
|
|
|
|
|
|
|
|
text = text.lower()
|
|
|
|
ntext = ""
|
|
|
|
for i in text:
|
|
|
|
if i in good:
|
|
|
|
ntext = ntext + i
|
|
|
|
else:
|
|
|
|
ntext = ntext + "_"
|
|
|
|
|
|
|
|
return ntext
|
2024-11-19 19:04:03 +02:00
|
|
|
|
2024-11-23 00:48:29 +02:00
|
|
|
def Safe(text):
|
|
|
|
return text.replace("<", "<").replace(">", ">")
|
|
|
|
|
2024-11-19 19:04:03 +02:00
|
|
|
def RandString(n=50):
|
|
|
|
# this will make a random string
|
|
|
|
s = ""
|
|
|
|
good = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890"
|
|
|
|
|
|
|
|
for i in range(n):
|
|
|
|
s = s + random.choice(good)
|
|
|
|
|
|
|
|
return s
|
|
|
|
|
|
|
|
|
|
|
|
IDColors = {}
|
|
|
|
|
|
|
|
def consoleForm(obj):
|
|
|
|
|
|
|
|
# Function that prints a pretty object info about
|
|
|
|
|
2024-11-20 14:40:56 +02:00
|
|
|
if not obj: obj = "Anonymous"
|
|
|
|
|
2024-11-19 19:04:03 +02:00
|
|
|
ID = obj
|
|
|
|
NAME = obj[-10:]
|
|
|
|
|
|
|
|
c = IDcolor(ID)
|
|
|
|
|
|
|
|
return c + " " + NAME + " " + clr["norm"]
|
|
|
|
|
|
|
|
def IDcolor(ID):
|
|
|
|
|
|
|
|
# Coloring
|
|
|
|
if ID not in IDColors:
|
|
|
|
r = random.random()
|
|
|
|
g = random.random()
|
|
|
|
b = random.random()
|
|
|
|
|
|
|
|
ct = clr["tbwh"]
|
|
|
|
if max(r, g, b ) > 0.9 or sum((r, g, b))/3 > 0.5:
|
|
|
|
ct = clr["tdbl"]
|
|
|
|
|
|
|
|
c = clr["bold"] + "\033[48;2;"+str(int(r*256))+";"+str(int(g*256))+";"+str(int(b*256))+"m"+ct
|
|
|
|
IDColors[ID] = c
|
|
|
|
c = IDColors[ID]
|
|
|
|
return c
|
2024-11-20 14:40:56 +02:00
|
|
|
|