From: Joachim Kuebart Date: Sat, 18 Dec 2021 07:44:53 GMT Subject: Re: [PATCH v2 1/2] git-p4: print size values in appropriate units Message-ID: <39F3A9A9-AE61-4C2E-AA66-6B072634D91E@gmail.com> In-Reply-To: <20211217203856.2339161-2-jholdsworth@nvidia.com> > On 17 Dec 2021, at 21:38, Joel Holdsworth 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