git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Joachim Kuebart <joachim.kuebart@gmail.com>
Date
Dec 18, 2021, 07:44 UTC
Message-ID
<39F3A9A9-AE61-4C2E-AA66-6B072634D91E@gmail.com>
In-Reply-To
<20211217203856.2339161-2-jholdsworth@nvidia.com>
Show 22 quoted lines
> On 17 Dec 2021, at 21:38, Joel Holdsworth <jholdsworth@nvidia.com> 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

Previous: Joel HoldsworthNext: Luke Diamand
Message 3 of 7 in “git-p4: improve formatting of numeric values”
  1. 0/2 git-p4: improve formatting of numeric valuesJoel Holdsworth, Dec 17, 2021
  2. 1/2 git-p4: print size values in appropriate unitsJoel Holdsworth, Dec 17, 2021
  3. Joachim KuebartDec 18, 2021
  4. Luke DiamandDec 18, 2021
  5. 2/2 git-p4: show progress as an integerJoel Holdsworth, Dec 17, 2021
  6. Luke DiamandDec 18, 2021
  7. Junio C HamanoDec 20, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.