Skip to content

Commit b40ca3d

Browse files
committed
fix double loader toggle on get_input
1 parent 4cb02d0 commit b40ca3d

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

zotify/termoutput.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,38 +115,38 @@ def _print_prefixes(msg: str, category: PrintCategory, channel: PrintChannel) ->
115115
return category.value + msg
116116

117117
@staticmethod
118-
def _toggle_active_loader(loader: bool = False):
118+
def _toggle_active_loader(skip_toggle: bool = False):
119119
global ACTIVE_LOADER
120-
if not loader and ACTIVE_LOADER:
120+
if not skip_toggle and ACTIVE_LOADER:
121121
if ACTIVE_LOADER.paused:
122122
ACTIVE_LOADER.resume()
123123
else:
124124
ACTIVE_LOADER.pause()
125125

126126
@staticmethod
127-
def new_print(channel: PrintChannel, msg: str, category: PrintCategory = PrintCategory.NONE, loader: bool = False, end: str = "\n") -> None:
127+
def new_print(channel: PrintChannel, msg: str, category: PrintCategory = PrintCategory.NONE, skip_toggle: bool = False, end: str = "\n") -> None:
128128
global LAST_PRINT
129129
if channel != PrintChannel.MANDATORY:
130130
from zotify.config import Zotify
131131
if channel == PrintChannel.MANDATORY or Zotify.CONFIG.get(channel.value):
132132
msg = Printer._print_prefixes(msg, category, channel)
133133
if channel == PrintChannel.DEBUG and Zotify.CONFIG.logger:
134134
Zotify.CONFIG.logger.debug(msg.strip().replace("DEBUG", "\n") + "\n")
135-
Printer._toggle_active_loader(loader)
135+
Printer._toggle_active_loader(skip_toggle)
136136
for line in str(msg).splitlines():
137137
if end == "\n":
138138
tqdm.write(line.ljust(Printer._term_cols()))
139139
else:
140140
tqdm.write(line, end=end)
141141
LAST_PRINT = category
142-
Printer._toggle_active_loader(loader)
142+
Printer._toggle_active_loader(skip_toggle)
143143

144144
@staticmethod
145145
def get_input(prompt: str) -> str:
146146
user_input = ""
147147
Printer._toggle_active_loader()
148148
while len(user_input) == 0:
149-
Printer.new_print(PrintChannel.MANDATORY, prompt, PrintCategory.GENERAL, end="")
149+
Printer.new_print(PrintChannel.MANDATORY, prompt, PrintCategory.GENERAL, end="", skip_toggle=True)
150150
user_input = str(input())
151151
Printer._toggle_active_loader()
152152
return user_input
@@ -292,7 +292,7 @@ def __init__(self, chan, desc="Loading...", end='', timeout=0.1, mode='prog'):
292292
self.dead = False
293293

294294
def _loader_print(self, msg: str):
295-
Printer.new_print(self.channel, msg, self.category, loader=True)
295+
Printer.new_print(self.channel, msg, self.category, skip_toggle=True)
296296

297297
if self.category is PrintCategory.LOADER:
298298
self.category = PrintCategory.LOADER_CYCLE

0 commit comments

Comments
 (0)