MCPcopy
hub / github.com/tqdm/tqdm / display

Method display

tqdm/notebook.py:141–192  ·  view source on GitHub ↗
(self, msg=None, pos=None,
                # additional signals
                close=False, bar_style=None, check_delay=True)

Source from the content-addressed store, hash-verified

139 return container
140
141 def display(self, msg=None, pos=None,
142 # additional signals
143 close=False, bar_style=None, check_delay=True):
144 # Note: contrary to native tqdm, msg='' does NOT clear bar
145 # goal is to keep all infos if error happens so user knows
146 # at which iteration the loop failed.
147
148 # Clear previous output (really necessary?)
149 # clear_output(wait=1)
150
151 if not msg and not close:
152 d = self.format_dict
153 # remove {bar}
154 d['bar_format'] = (d['bar_format'] or "{l_bar}<bar/>{r_bar}").replace(
155 "{bar}", "<bar/>")
156 msg = self.format_meter(**d)
157
158 ltext, pbar, rtext = self.container.children
159 pbar.value = self.n
160
161 if msg:
162 msg = msg.replace(' ', '\u2007') # fix html space padding
163 # html escape special characters (like '&')
164 if '<bar/>' in msg:
165 left, right = map(escape, re.split(r'\|?<bar/>\|?', msg, maxsplit=1))
166 else:
167 left, right = '', escape(msg)
168
169 # Update description
170 ltext.value = left
171 # never clear the bar (signal: msg='')
172 if right:
173 rtext.value = right
174
175 # Change bar style
176 if bar_style:
177 # Hack-ish way to avoid the danger bar_style being overridden by
178 # success because the bar gets closed after the error...
179 if pbar.bar_style != 'danger' or bar_style != 'success':
180 pbar.bar_style = bar_style
181
182 # Special signal to close the bar
183 if close and pbar.bar_style != 'danger': # hide only if no error
184 try:
185 self.container.close()
186 except AttributeError:
187 self.container.visible = False
188 self.container.layout.visibility = 'hidden' # IPYW>=8
189
190 if check_delay and self.delay > 0 and not self.displayed:
191 display(self.container)
192 self.displayed = True
193
194 @property
195 def colour(self):

Callers 1

__init__Method · 0.95

Calls 2

format_meterMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected