Method: rich.progress.track
Calls: 1, Exceptions: 0, Paths: 1Back
Path 1: 1 calls (1.0)
['foo', 'bar', 'baz'] (1)
'test' (1)
None (1)
False (1)
Console (1)
False (1)
MockClock (1)
10 (1)
'bar.back' (1)
'bar.complete' (1)
'bar.finished' (1)
'bar.pulse' (1)
0.1 (1)
False (1)
True (1)
'foo' (1) 'bar' (1) 'baz' (1)
1def track(
2 sequence: Union[Sequence[ProgressType], Iterable[ProgressType]],
3 description: str = "Working...",
4 total: Optional[float] = None,
5 auto_refresh: bool = True,
6 console: Optional[Console] = None,
7 transient: bool = False,
8 get_time: Optional[Callable[[], float]] = None,
9 refresh_per_second: float = 10,
10 style: StyleType = "bar.back",
11 complete_style: StyleType = "bar.complete",
12 finished_style: StyleType = "bar.finished",
13 pulse_style: StyleType = "bar.pulse",
14 update_period: float = 0.1,
15 disable: bool = False,
16 show_speed: bool = True,
17) -> Iterable[ProgressType]:
18 """Track progress by iterating over a sequence.
19
20 Args:
21 sequence (Iterable[ProgressType]): A sequence (must support "len") you wish to iterate over.
22 description (str, optional): Description of task show next to progress bar. Defaults to "Working".
23 total: (float, optional): Total number of steps. Default is len(sequence).
24 auto_refresh (bool, optional): Automatic refresh, disable to force a refresh after each iteration. Default is True.
25 transient: (bool, optional): Clear the progress on exit. Defaults to False.
26 console (Console, optional): Console to write to. Default creates internal Console instance.
27 refresh_per_second (float): Number of times per second to refresh the progress information. Defaults to 10.
28 style (StyleType, optional): Style for the bar background. Defaults to "bar.back".
29 complete_style (StyleType, optional): Style for the completed bar. Defaults to "bar.complete".
30 finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
31 pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
32 update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
33 disable (bool, optional): Disable display of progress.
34 show_speed (bool, optional): Show speed if total isn't known. Defaults to True.
35 Returns:
36 Iterable[ProgressType]: An iterable of the values in the sequence.
37
38 """
39
40 columns: List["ProgressColumn"] = (
41 [TextColumn("[progress.description]{task.description}")] if description else []
42 )
43 columns.extend(
44 (
45 BarColumn(
46 style=style,
47 complete_style=complete_style,
48 finished_style=finished_style,
49 pulse_style=pulse_style,
50 ),
51 TaskProgressColumn(show_speed=show_speed),
52 TimeRemainingColumn(),
53 )
54 )
55 progress = Progress(
56 *columns,
57 auto_refresh=auto_refresh,
58 console=console,
59 transient=transient,
60 get_time=get_time,
61 refresh_per_second=refresh_per_second or 10,
62 disable=disable,
63 )
64
65 with progress:
66 yield from progress.track(
67 sequence, total=total, description=description, update_period=update_period
68 )