MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / display

Method display

pager_lib/tqdm/notebook.py:139–190  ·  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

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

Callers 1

__init__Method · 0.95

Calls 2

format_meterMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected