[1bdb11]: / aitrika / utils / loader.py

Download this file

22 lines (15 with data), 438 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from yaspin import yaspin
def loader(text: str):
"""
Custom spinner for terminal.
Args:
text (str): Text to display
"""
def decorator(func):
def wrapper(self, *args, **kwargs):
with yaspin(text=text, color="cyan") as sp:
result = func(self, *args, **kwargs)
sp.ok("✔")
return f"\n{result}"
return wrapper
return decorator