Skip to content

Commit

Permalink
Adds expand to track, wrap_file and open
Browse files Browse the repository at this point in the history
  • Loading branch information
PeiPei233 committed Dec 16, 2024
1 parent 43d3b04 commit bff3513
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def track(
update_period: float = 0.1,
disable: bool = False,
show_speed: bool = True,
expand: bool = False,
) -> Iterable[ProgressType]:
"""Track progress by iterating over a sequence.
Expand All @@ -141,6 +142,7 @@ def track(
update_period (float, optional): Minimum time (in seconds) between calls to update(). Defaults to 0.1.
disable (bool, optional): Disable display of progress.
show_speed (bool, optional): Show speed if total isn't known. Defaults to True.
expand (bool, optional): Expand the progress display to fill the width of the console. Defaults to False.
Returns:
Iterable[ProgressType]: An iterable of the values in the sequence.
Expand All @@ -152,6 +154,7 @@ def track(
columns.extend(
(
BarColumn(
bar_width=None if expand else 40,
style=style,
complete_style=complete_style,
finished_style=finished_style,
Expand All @@ -169,6 +172,7 @@ def track(
get_time=get_time,
refresh_per_second=refresh_per_second or 10,
disable=disable,
expand=expand,
)

with progress:
Expand Down Expand Up @@ -320,6 +324,7 @@ def wrap_file(
finished_style: StyleType = "bar.finished",
pulse_style: StyleType = "bar.pulse",
disable: bool = False,
expand: bool = False,
) -> ContextManager[BinaryIO]:
"""Read bytes from a file while tracking progress.
Expand All @@ -336,6 +341,7 @@ def wrap_file(
finished_style (StyleType, optional): Style for a finished bar. Defaults to "bar.finished".
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
disable (bool, optional): Disable display of progress.
expand (bool, optional): Expand the progress display to fill the width of the console. Defaults to False.
Returns:
ContextManager[BinaryIO]: A context manager yielding a progress reader.
Expand All @@ -347,6 +353,7 @@ def wrap_file(
columns.extend(
(
BarColumn(
bar_width=None if expand else 40,
style=style,
complete_style=complete_style,
finished_style=finished_style,
Expand All @@ -364,6 +371,7 @@ def wrap_file(
get_time=get_time,
refresh_per_second=refresh_per_second or 10,
disable=disable,
expand=expand,
)

reader = progress.wrap_file(file, total=total, description=description)
Expand Down Expand Up @@ -391,6 +399,7 @@ def open(
finished_style: StyleType = "bar.finished",
pulse_style: StyleType = "bar.pulse",
disable: bool = False,
expand: bool = False,
) -> ContextManager[TextIO]:
pass

Expand All @@ -416,6 +425,7 @@ def open(
finished_style: StyleType = "bar.finished",
pulse_style: StyleType = "bar.pulse",
disable: bool = False,
expand: bool = False,
) -> ContextManager[BinaryIO]:
pass

Expand All @@ -440,6 +450,7 @@ def open(
finished_style: StyleType = "bar.finished",
pulse_style: StyleType = "bar.pulse",
disable: bool = False,
expand: bool = False,
) -> Union[ContextManager[BinaryIO], ContextManager[TextIO]]:
"""Read bytes from a file while tracking progress.
Expand All @@ -462,6 +473,7 @@ def open(
pulse_style (StyleType, optional): Style for pulsing bars. Defaults to "bar.pulse".
disable (bool, optional): Disable display of progress.
encoding (str, optional): The encoding to use when reading in text mode.
expand (bool, optional): Expand the progress display to fill the width of the console. Defaults to False.
Returns:
ContextManager[BinaryIO]: A context manager yielding a progress reader.
Expand All @@ -474,6 +486,7 @@ def open(
columns.extend(
(
BarColumn(
bar_width=None if expand else 40,
style=style,
complete_style=complete_style,
finished_style=finished_style,
Expand All @@ -491,6 +504,7 @@ def open(
get_time=get_time,
refresh_per_second=refresh_per_second or 10,
disable=disable,
expand=expand,
)

reader = progress.open(
Expand Down

0 comments on commit bff3513

Please sign in to comment.