Skip to content

Commit 4cb02d0

Browse files
committed
fix bug with get_input if loader running
version bump v0.9.12
1 parent 046a037 commit 4cb02d0

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

zotify/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
__version__ = "0.9.11"
2+
__version__ = "0.9.12"
33

44
from enum import IntEnum
55
from http.server import BaseHTTPRequestHandler, HTTPServer

zotify/termoutput.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,41 @@ def _print_prefixes(msg: str, category: PrintCategory, channel: PrintChannel) ->
114114

115115
return category.value + msg
116116

117+
@staticmethod
118+
def _toggle_active_loader(loader: bool = False):
119+
global ACTIVE_LOADER
120+
if not loader and ACTIVE_LOADER:
121+
if ACTIVE_LOADER.paused:
122+
ACTIVE_LOADER.resume()
123+
else:
124+
ACTIVE_LOADER.pause()
125+
117126
@staticmethod
118127
def new_print(channel: PrintChannel, msg: str, category: PrintCategory = PrintCategory.NONE, loader: bool = False, end: str = "\n") -> None:
119128
global LAST_PRINT
120129
if channel != PrintChannel.MANDATORY:
121130
from zotify.config import Zotify
122131
if channel == PrintChannel.MANDATORY or Zotify.CONFIG.get(channel.value):
123-
global ACTIVE_LOADER
124-
if not loader and ACTIVE_LOADER:
125-
ACTIVE_LOADER.pause()
126132
msg = Printer._print_prefixes(msg, category, channel)
127133
if channel == PrintChannel.DEBUG and Zotify.CONFIG.logger:
128134
Zotify.CONFIG.logger.debug(msg.strip().replace("DEBUG", "\n") + "\n")
135+
Printer._toggle_active_loader(loader)
129136
for line in str(msg).splitlines():
130137
if end == "\n":
131138
tqdm.write(line.ljust(Printer._term_cols()))
132139
else:
133140
tqdm.write(line, end=end)
134141
LAST_PRINT = category
135-
if not loader and ACTIVE_LOADER:
136-
ACTIVE_LOADER.resume()
142+
Printer._toggle_active_loader(loader)
137143

138144
@staticmethod
139145
def get_input(prompt: str) -> str:
140146
user_input = ""
147+
Printer._toggle_active_loader()
141148
while len(user_input) == 0:
142149
Printer.new_print(PrintChannel.MANDATORY, prompt, PrintCategory.GENERAL, end="")
143150
user_input = str(input())
151+
Printer._toggle_active_loader()
144152
return user_input
145153

146154
# Print Wrappers

0 commit comments

Comments
 (0)