-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
35 lines (33 loc) · 1.13 KB
/
utils.py
File metadata and controls
35 lines (33 loc) · 1.13 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
import sys
import time
def typing_effect(text, speed=0.03):
"""
Simulates a hacker-style typing effect.
Includes interrupt handling to skip the animation if Ctrl+C is pressed.
"""
try:
for char in text:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(speed)
print()
except KeyboardInterrupt:
# If interrupted, print the remaining text immediately and move on
sys.stdout.write('\r' + text + '\n')
sys.stdout.flush()
def progress_bar(seconds):
"""
Displays a visual progress bar for 'loading' sequences.
Handles Ctrl+C to jump to 100% and continue.
"""
try:
for i in range(1, 21):
time.sleep(seconds / 20)
# Visual representation using '#' for progress and '.' for remaining space
sys.stdout.write(f"\r[SYSTEM] Progress: [{'#' * i}{'.' * (20 - i)}] {i * 5}%")
sys.stdout.flush()
print()
except KeyboardInterrupt:
# Jump to completed bar on interrupt
sys.stdout.write(f"\r[SYSTEM] Progress: [{'#' * 20}] 100% - INTERRUPTED\n")
sys.stdout.flush()