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

Method wrapattr

pager_lib/tqdm/std.py:1502–1519  ·  view source on GitHub ↗

stream : file-like object. method : str, "read" or "write". The result of `read()` and the first argument of `write()` should have a `len()`. >>> with tqdm.wrapattr(file_obj, "read", total=file_obj.size) as fobj: ... while True: ...

(cls, stream, method, total=None, bytes=True, **tqdm_kwargs)

Source from the content-addressed store, hash-verified

1500 @classmethod
1501 @contextmanager
1502 def wrapattr(cls, stream, method, total=None, bytes=True, **tqdm_kwargs):
1503 """
1504 stream : file-like object.
1505 method : str, "read" or "write". The result of `read()` and
1506 the first argument of `write()` should have a `len()`.
1507
1508 >>> with tqdm.wrapattr(file_obj, "read", total=file_obj.size) as fobj:
1509 ... while True:
1510 ... chunk = fobj.read(chunk_size)
1511 ... if not chunk:
1512 ... break
1513 """
1514 with cls(total=total, **tqdm_kwargs) as t:
1515 if bytes:
1516 t.unit = "B"
1517 t.unit_scale = True
1518 t.unit_divisor = 1024
1519 yield CallbackIOWrapper(t.update, stream, method)
1520
1521
1522def trange(*args, **kwargs):

Callers

nothing calls this directly

Calls 1

CallbackIOWrapperClass · 0.85

Tested by

no test coverage detected