mirror of
https://github.com/tildeclub/ttbp.git
synced 2026-06-24 21:09:23 +00:00
color and code cleanup
added color generation to banner! converting more static text to here docs.
This commit is contained in:
37
bin/util.py
37
bin/util.py
@@ -3,9 +3,46 @@
|
||||
import inflect
|
||||
import time
|
||||
import random
|
||||
import colorama
|
||||
|
||||
colorama.init()
|
||||
|
||||
textcolors = [ colorama.Fore.RED, colorama.Fore.GREEN, colorama.Fore.YELLOW, colorama.Fore.BLUE, colorama.Fore.MAGENTA, colorama.Fore.WHITE, colorama.Fore.CYAN]
|
||||
|
||||
lastcolor = colorama.Fore.RESET
|
||||
|
||||
p = inflect.engine()
|
||||
|
||||
def set_rainbow():
|
||||
global lastcolor
|
||||
|
||||
color = lastcolor
|
||||
while color == lastcolor:
|
||||
color = random.choice(textcolors)
|
||||
|
||||
lastcolor = color
|
||||
|
||||
print(color)
|
||||
|
||||
def reset_color():
|
||||
print(colorama.Fore.RESET)
|
||||
|
||||
def attach_rainbow():
|
||||
global lastcolor
|
||||
|
||||
color = lastcolor
|
||||
while color == lastcolor:
|
||||
color = random.choice(textcolors)
|
||||
|
||||
lastcolor = color
|
||||
return color
|
||||
|
||||
def attach_reset():
|
||||
return colorama.Style.RESET_ALL
|
||||
|
||||
def hilight(text):
|
||||
return colorama.Style.BRIGHT+text+colorama.Style.NORMAL
|
||||
|
||||
def pretty_time(time):
|
||||
m, s = divmod(time, 60)
|
||||
if m > 0:
|
||||
|
||||
Reference in New Issue
Block a user