Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	rich/progress.py
This commit is contained in:
amartya-dev 2020-10-14 19:47:58 +05:30
commit c4c131654d

View file

@ -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