Created
June 12, 2021 19:53
-
-
Save dannluciano/1ff6f6029f4b8f384eb0d6e4322da859 to your computer and use it in GitHub Desktop.
Loader in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
cols = 59 | |
steps = 100 | |
if len(sys.argv) > 2: | |
steps = int(sys.argv[1]) | |
for s in range(steps): | |
percent = s / steps * cols-1 | |
real_percent = s / steps * 100 | |
print(f"\r{real_percent:6.2f} [", end='') | |
i = 0 | |
while i < percent and i < cols: | |
i+=1 | |
print('=', end='') | |
print('>', end='') | |
i+=1 | |
while i > percent and i < cols: | |
i+=1 | |
print(' ', end='') | |
loading = "-\\|/" | |
char = loading[s%4] | |
print(f"] {char} ETA {steps-s}", end='', flush=True) | |
time.sleep(1) | |
print("\nFinished!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment