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)
| 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 | |
| 1522 | def trange(*args, **kwargs): |
nothing calls this directly
no test coverage detected