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

Method update

pager_lib/tqdm/std.py:1198–1263  ·  view source on GitHub ↗

Manually update the progress bar, useful for streams such as reading files. E.g.: >>> t = tqdm(total=filesize) # Initialise >>> for current_buffer in stream: ... ... ... t.update(len(current_buffer)) >>> t.close() The las

(self, n=1)

Source from the content-addressed store, hash-verified

1196 self.close()
1197
1198 def update(self, n=1):
1199 """
1200 Manually update the progress bar, useful for streams
1201 such as reading files.
1202 E.g.:
1203 >>> t = tqdm(total=filesize) # Initialise
1204 >>> for current_buffer in stream:
1205 ... ...
1206 ... t.update(len(current_buffer))
1207 >>> t.close()
1208 The last line is highly recommended, but possibly not necessary if
1209 `t.update()` will be called in such a way that `filesize` will be
1210 exactly reached and printed.
1211
1212 Parameters
1213 ----------
1214 n : int or float, optional
1215 Increment to add to the internal counter of iterations
1216 [default: 1]. If using float, consider specifying `{n:.3f}`
1217 or similar in `bar_format`, or specifying `unit_scale`.
1218
1219 Returns
1220 -------
1221 out : bool or None
1222 True if a `display()` was triggered.
1223 """
1224 if self.disable:
1225 return
1226
1227 if n < 0:
1228 self.last_print_n += n # for auto-refresh logic to work
1229 self.n += n
1230
1231 # check counter first to reduce calls to time()
1232 if self.n - self.last_print_n >= self.miniters:
1233 cur_t = self._time()
1234 dt = cur_t - self.last_print_t
1235 if dt >= self.mininterval and cur_t >= self.start_t + self.delay:
1236 cur_t = self._time()
1237 dn = self.n - self.last_print_n # >= n
1238 if self.smoothing and dt and dn:
1239 # EMA (not just overall average)
1240 self._ema_dn(dn)
1241 self._ema_dt(dt)
1242 self.refresh(lock_args=self.lock_args)
1243 if self.dynamic_miniters:
1244 # If no `miniters` was specified, adjust automatically to the
1245 # maximum iteration rate seen so far between two prints.
1246 # e.g.: After running `tqdm.update(5)`, subsequent
1247 # calls to `tqdm.update()` will only cause an update after
1248 # at least 5 more iterations.
1249 if self.maxinterval and dt >= self.maxinterval:
1250 self.miniters = dn * (self.mininterval or self.maxinterval) / dt
1251 elif self.smoothing:
1252 # EMA miniters update
1253 self.miniters = self._ema_miniters(
1254 dn * (self.mininterval / dt if self.mininterval and dt
1255 else 1))

Callers 15

__iter__Method · 0.95
load_configMethod · 0.45
_derive_lan_networksMethod · 0.45
_coordinator_nodesMethod · 0.45
do_dns_doctorFunction · 0.45
do_flow_telemetryFunction · 0.45
md5Function · 0.45
_write_pwn_status_fileFunction · 0.45

Calls 1

refreshMethod · 0.95

Tested by 1

_base_alertFunction · 0.36