mirror of
https://github.com/Textualize/rich.git
synced 2025-08-31 15:37:24 +00:00
Merge remote-tracking branch 'origin/master' into master
# Conflicts: # rich/progress.py
This commit is contained in:
commit
c4c131654d
1 changed files with 8 additions and 8 deletions
|
@ -294,27 +294,27 @@ class DownloadColumn(ProgressColumn):
|
|||
"""Renders file size downloaded and total, e.g. '0.5/2.3 GB'.
|
||||
|
||||
Args:
|
||||
binary_units (bool, optional): Flag to renser filesize in desired format, disable to render in binary. Defaults to True.
|
||||
decimal_suffix (bool, optional): Flag to render filesize in decimal format, disable to render in binary. Defaults to True.
|
||||
"""
|
||||
|
||||
def __init__(self, binary_units: bool = False) -> None:
|
||||
self.binary_units = binary_units
|
||||
def __init__(self, decimal_suffix: bool = True) -> None:
|
||||
self.decimal_ssuffix = decimal_suffix
|
||||
super().__init__()
|
||||
|
||||
def render(self, task: "Task") -> Text:
|
||||
"""Calculate common unit for completed and total."""
|
||||
completed = int(task.completed)
|
||||
total = int(task.total)
|
||||
if self.binary_units:
|
||||
if self.decimal_ssuffix:
|
||||
unit, suffix = filesize.pick_unit_and_suffix(
|
||||
total, ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], 1000
|
||||
)
|
||||
else:
|
||||
unit, suffix = filesize.pick_unit_and_suffix(
|
||||
total,
|
||||
["bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"],
|
||||
1024,
|
||||
)
|
||||
else:
|
||||
unit, suffix = filesize.pick_unit_and_suffix(
|
||||
total, ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], 1000
|
||||
)
|
||||
completed_ratio = completed / unit
|
||||
total_ratio = total / unit
|
||||
precision = 0 if unit == 1 else 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue