Coverage for src/susi/utils/progress.py: 100%
16 statements
« prev ^ index » next coverage.py v7.5.0, created at 2025-06-13 14:15 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2025-06-13 14:15 +0000
1"""
2module provides functions to print progress to the shell
3"""
5RESET = '\033[1;0m'
6GREEN = '\033[1;32m'
7RED = '\033[1;31m'
10def dot(success: bool = True, flush: bool = False, char: str = '*') -> None:
11 """Print a progress dot to std. out"""
12 if flush:
13 print('')
14 else:
15 print(f'{GREEN if success else RED}{char}{RESET}', end='', flush=True)
18def bar(current: float, total: float, flush: bool = False, length: int = 50) -> None:
19 """print a progress bar and a percent of completion to std. out """
20 percent = (current * 100) / total
21 done = int(round(length * (percent/100)))
22 prog = ''.join(['━' for _ in range(done)])
23 empty = ''.join([' ' for _ in range(length - done)])
24 stop = '┃' if len(empty) > 0 else '┫'
25 print(f'┣{prog}{empty}{stop} \t[{percent:.2f} %]', end='\r', flush=True)
26 if flush:
27 print('')