-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterminal_utils.py
More file actions
31 lines (23 loc) · 927 Bytes
/
Copy pathterminal_utils.py
File metadata and controls
31 lines (23 loc) · 927 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
30
31
from colorama import Fore
def user_choice_bool(prompt: str) -> bool:
"""
Prompts the user if they want to prompt. Accepts Y/y or N/n
"""
while True:
try:
choice = input(f"\n{prompt}").strip().lower()
if choice == 'y':
return True
elif choice == 'n':
return False
else:
print("Invalid Input")
except KeyboardInterrupt:
raise KeyboardInterrupt
def pretty_substring(str: str, substr: str, start: str = "", end="", color_a=Fore.RED, color_b=Fore.YELLOW):
str_len = len(str)
substr_len = len(substr)
index = str.lower().find(substr.lower())
string = color_a + start + str[0: index] + color_b + str[index: index +
substr_len] + color_a + str[index + substr_len: str_len] + end + Fore.RESET
return string