Method: rich.progress.wrap_file
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
BufferedReader (1)
13 (1)
'Reading...' (1)
True (1)
None (1)
False (1)
None (1)
10 (1)
'bar.back' (1)
'bar.complete' (1)
'bar.finished' (1)
'bar.pulse' (1)
False (1)
_ReadContext (1)
1def wrap_file(
2 file: BinaryIO,
3 total: int,
4 *,
5 description: str = "Reading...",
6 auto_refresh: bool = True,
7 console: Optional[Console] = None,
8 transient: bool = False,
9 get_time: Optional[Callable[[], float]] = None,
10 refresh_per_second: float = 10,
11 style: StyleType = "bar.back",
12 complete_style: StyleType = "bar.complete",
13 finished_style: StyleType = "bar.finished",
14 pulse_style: StyleType = "bar.pulse",
15 disable: bool = False,
16) -> ContextManager[BinaryIO]:
17 """Read bytes from a file while tracking progress.
18
19 Args:
20 file (Union[str, PathLike[str], BinaryIO]): The path to the file to read, or a file-like object in binary mode.
21 total (int): Total number of bytes to read.
22 description (str, optional): Description of task show next to progress bar. Defaults to "Reading".
23 auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
24 transient: (bool, optional): Clear the progress on exit. Defaults to False.
25 console (Console, optional): Console to write to. Default creates internal Console instance.
26 refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
27 style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
28 complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
29 finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
30 pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
31 disable (bool, optional): Disable display of progress.
32 Returns:
33 ContextManager[BinaryIO]: A context manager yielding a progress reader.
34
35 """
36
37 columns: List["ProgressColumn"] = (
38 [TextColumn("[progress.description]{task.description}")] if description else []
39 )
40 columns.extend(
41 (
42 BarColumn(
43 style=style,
44 complete_style=complete_style,
45 finished_style=finished_style,
46 pulse_style=pulse_style,
47 ),
48 DownloadColumn(),
49 TimeRemainingColumn(),
50 )
51 )
52 progress = Progress(
53 *columns,
54 auto_refresh=auto_refresh,
55 console=console,
56 transient=transient,
57 get_time=get_time,
58 refresh_per_second=refresh_per_second or 10,
59 disable=disable,
60 )
61
62 reader = progress.wrap_file(file, total=total, description=description)
63 return _ReadContext(progress, reader)