-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmess.py
More file actions
executable file
·111 lines (86 loc) · 3.23 KB
/
Copy pathmess.py
File metadata and controls
executable file
·111 lines (86 loc) · 3.23 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
#!/usr/bin/env python3
#[x-cmds]: UPDATE
"""Displays an animated, random text character mess.
The mess can be made faster and displayed in color."""
from xulbux import FormatCodes, Console
import random
import time
ARGS = Console.get_args({
"fast_mode": {"-f", "--fast"},
"color_mode": {"-c", "--color"},
"help": {"-h", "--help"},
})
rand_choice = random.choice
rand_bits = random.getrandbits
fc_print = FormatCodes.print
sleep = time.sleep
def print_help():
help_text = """
[b|in|bg:black]( Mess — Display an animated random text character mess )
[b](Usage:) [br:green](mess) [br:blue]([options])
[b](Options:)
[br:blue](-f), [br:blue](--fast) Display the mess at maximum speed
[br:blue](-c), [br:blue](--color) Color the mess in random colors
[b](Controls:)
[br:red](Ctrl(⌘)[dim](+)C) Stop the animation
[b](Examples:)
[br:green](mess) [dim](# [i](Show binary mess at normal speed))
[br:green](mess) [br:blue](--fast) [dim](# [i](Show binary mess at maximum speed))
[br:green](mess) [br:blue](--color) [dim](# [i](Show colorful binary mess))
[br:green](mess) [br:blue](-f -c) [dim](# [i](Show colorful binary mess at maximum speed))
"""
FormatCodes.print(help_text)
x = ["0", "1"]
f = ["dim", "bold", "inverse", "underline", "strikethrough", "double-underline"]
if ARGS.color_mode.exists:
f.extend([
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "BR:black", "BR:red", "BR:green", "BR:yellow",
"BR:blue", "BR:magenta", "BR:cyan", "BR:white", "BG:black", "BG:red", "BG:green", "BG:yellow", "BG:blue", "BG:magenta",
"BG:cyan", "BG:white", "BG:BR:black", "BG:BR:red", "BG:BR:green", "BG:BR:yellow", "BG:BR:blue", "BG:BR:magenta",
"BG:BR:cyan", "BG:BR:white", "randomCL", "randomBG"
])
def random_hexa() -> str:
return f"#{random.randint(0, 255):02X}{random.randint(0, 255):02X}{random.randint(0, 255):02X}"
def replace_special(text: str) -> str:
return text.replace("randomCL", random_hexa()).replace("randomBG", f"BG:{random_hexa()}")
def rand_binary_line() -> str:
return "".join(
(f"[{rand_choice(f)}]" if rand_bits(1) else "") \
+ (rand_choice(x) if rand_bits(1) else " ")
+ "[_]"
for _ in range(Console.width)
)
def rand_color_binary_line() -> str:
return "".join(
(f"[{replace_special(rand_choice(f))}]" if rand_bits(1) else "") \
+ (rand_choice(x) if rand_bits(1) else " ")
+ "[_]"
for _ in range(Console.width)
)
def main() -> None:
if ARGS.help.exists:
print_help()
return
if ARGS.color_mode.exists:
if ARGS.fast_mode.exists:
while True:
fc_print(rand_color_binary_line())
else:
while True:
fc_print(rand_color_binary_line())
sleep(0.025)
else:
if ARGS.fast_mode.exists:
while True:
fc_print(rand_binary_line())
else:
while True:
fc_print(rand_binary_line())
sleep(0.025)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print()
except Exception as exc:
Console.fail(exc, start="\n", end="\n\n")