-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
29 lines (26 loc) · 1011 Bytes
/
utils.py
File metadata and controls
29 lines (26 loc) · 1011 Bytes
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
import time
from colorama import Fore, Style, Back
def type_print(text, delay=0.02, fore=Fore.WHITE, back=Back.RESET):
try:
for char in text:
print(back + fore + char + Style.RESET_ALL, end='', flush=True)
time.sleep(delay)
print()
except KeyboardInterrupt:
print(Style.RESET_ALL)
def type_print_lines(text, char_delay=0.002, line_delay=0.1, fore=Fore.RED, back=Back.BLUE):
try:
for line in text.split('\n'):
for char in line:
print(back + fore + char + Style.RESET_ALL, end='', flush=True)
time.sleep(char_delay)
print()
time.sleep(line_delay)
except KeyboardInterrupt:
print(Style.RESET_ALL)
def build_language_list(languages: dict, per_line=5):
items = [f"{code}: {name}" for code, name in languages.items()]
lines = []
for i in range(0, len(items), per_line):
lines.append(" | ".join(items[i:i + per_line]))
return "\n".join(lines)