@@ -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