File: bytes.py

package info (click to toggle)
zabbix-cli 3.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: python: 19,920; makefile: 5
file content (11 lines) | stat: -rw-r--r-- 273 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
from __future__ import annotations

from pydantic import ByteSize

from .constants import NONE_STR


def bytesize_str(b: int | None, *, decimal: bool = False) -> str:
    if b is None or b < 0:
        return NONE_STR
    return ByteSize(b).human_readable(decimal=decimal)