File size: 446 Bytes
8044721
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env python3
# coding=utf-8

class LoadingBar:
    def __init__(self, length: int = 40):
        self.length = length
        self.symbols = ["β”ˆ", "β–‘", "β–’", "β–“"]

    def __call__(self, progress: float) -> str:
        p = int(progress * self.length * 4 + 0.5)
        d, r = p // 4, p % 4
        return "β” β”ˆ" + d * "β–ˆ" + ((self.symbols[r]) + max(0, self.length - 1 - d) * "β”ˆ" if p < self.length * 4 else "") + "β”ˆβ”¨"