-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloader.py
More file actions
30 lines (25 loc) · 743 Bytes
/
loader.py
File metadata and controls
30 lines (25 loc) · 743 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
from sys import stdout
from time import sleep
from math import floor
SYMBOLS = ["⋮", "⋰", "⋯", "⋱"]
class Loader:
count = 0
def load(self: object, percentage: float):
"""
:param percentage: float
- number between 0.0 and 100.0
"""
progress = '='*floor(float(percentage)/2)
left = ' '*(50-len(progress))
stdout.write('\r')
string = "{}% [{}] {}\t".format(int(percentage), progress + left, SYMBOLS[self.count % 4])
stdout.write(string)
stdout.flush()
self.count += 1
def main():
loader = Loader()
for i in range(101):
loader.load(i)
sleep(0.2)
if __name__ == "__main__":
main()