Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Functions
pip._vendor.rich.filesize Namespace Reference

Functions

str _to_str (int size, Iterable[str] suffixes, int base, *Optional[int] precision=1, Optional[str] separator=" ")
 
Tuple[int, str] pick_unit_and_suffix (int size, List[str] suffixes, int base)
 
str decimal (int size, *Optional[int] precision=1, Optional[str] separator=" ")
 

Detailed Description

Functions for reporting filesizes. Borrowed from https://github.com/PyFilesystem/pyfilesystem2

The functions declared in this module should cover the different
use cases needed to generate a string representation of a file size
using several different units. Since there are many standards regarding
file size units, three different functions have been implemented.

See Also:
    * `Wikipedia: Binary prefix <https://en.wikipedia.org/wiki/Binary_prefix>`_

Function Documentation

◆ decimal()

str pip._vendor.rich.filesize.decimal ( int  size,
*Optional[int]   precision = 1,
Optional[str]   separator = " " 
)
Convert a filesize in to a string (powers of 1000, SI prefixes).

In this convention, ``1000 B = 1 kB``.

This is typically the format used to advertise the storage
capacity of USB flash drives and the like (*256 MB* meaning
actually a storage capacity of more than *256 000 000 B*),
or used by **Mac OS X** since v10.6 to report file sizes.

Arguments:
    int (size): A file size.
    int (precision): The number of decimal places to include (default = 1).
    str (separator): The string to separate the value from the units (default = " ").

Returns:
    `str`: A string containing a abbreviated file size and units.

Example:
    >>> filesize.decimal(30000)
    '30.0 kB'
    >>> filesize.decimal(30000, precision=2, separator="")
    '30.00kB'

◆ pick_unit_and_suffix()

Tuple[int, str] pip._vendor.rich.filesize.pick_unit_and_suffix ( int  size,
List[str]  suffixes,
int  base 
)
Pick a suffix and base for the given size.