Re: [PATCH v2 1/2] git-p4: print size values in appropriate units

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 17 Dec 2021, at 21:38, Joel Holdsworth <jholdsworth@xxxxxxxxxx> wrote:
> 
> git-p4.py | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/git-p4.py b/git-p4.py
> index 2b4500226a..4d8a249b85 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -56,6 +56,16 @@
> 
> p4_access_checked = False
> 
> +def format_size_human_readable(num):
> +    """ Returns a number of units (typically bytes) formatted as a human-readable
> +        string.
> +    """
> +    for unit in ["", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"]:
> +        if abs(num) < 1024.0:
> +            return "{:3.1f} {}B".format(num, unit)
> +        num /= 1024.0
> +    return "{:.1f} Yi{}B".format(num)

This now has an extra pair of braces.

Cheers,
Joachim






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux