Updated for spinner message

This commit is contained in:
Dimitris Zlatanidis 2023-05-18 20:15:30 +03:00
parent caf29d6262
commit 4e8ded584a

View file

@ -19,6 +19,7 @@ class ProgressBar(Configs):
self.color: str = self.endc
self.spinners: dict = {}
self.spinners_color: dict = {}
self.bar_message: str = str()
def progress_bar(self, message: str, filename=None) -> None:
""" Creating progress bar. """
@ -26,14 +27,10 @@ class ProgressBar(Configs):
self.assign_spinner_colors()
self.set_spinner()
self.set_color()
bar_message: str = f"{self.endc}{message} "
if filename:
bar_message: str = (f"{'':>2}{self.red}{self.ascii.bullet}{self.endc} {filename}: "
f"{message}... ")
self.set_the_spinner_message(filename, message)
if self.spinning_bar:
bar_spinner = self.spinner(f'{bar_message}{self.color}')
bar_spinner = self.spinner(f'{self.bar_message}{self.color}')
# print('\033[F', end='', flush=True)
try:
while True:
@ -66,6 +63,12 @@ class ProgressBar(Configs):
'white': self.endc
}
def set_the_spinner_message(self, filename: str, message: str) -> None:
self.bar_message: str = f"{self.endc}{message} "
if filename:
self.bar_message: str = (f"{'':>2}{self.red}{self.ascii.bullet}{self.endc} {filename}: "
f"{message}... ")
def set_spinner(self) -> None:
try:
self.spinner: str = self.spinners[self.progress_spinner]