modunits module¶
Convert computer-friendly numbers to human-readable numbers with units at various levels of detail.
- class modunits.Item(amount: float, type_: Type, after: bool, units: str, fractional_part_length: int)[source]¶
Bases:
object
Hold one of the modular pieces of our number.
- class modunits.Type(threshold: int | None, unabbreviated: str, abbreviated: str)[source]¶
Bases:
object
Hold data about whether we should output units abbreviated or unabbreviated, and what to divide by (?).
- modunits.modunits(unitsvector: str | List[Type], number: int, detail: str = 'highest-and-fraction', units: str = 'abbreviated', comma: bool = True, reverse: bool = False, after: bool = True, fractional_part_length: int = -1)[source]¶
Convert a number with computer-friendly units into something more human-readable.
Main entry point for the module.
- detail can be:
list (implies that we will ignore units and comma) highest (implies that we will ignore comma) two-highest highest-and-fraction (default) all
- units can be:
unabbreviated abbreviated (default)
- comma can be:
0 (default) 1
- reverse can be:
0 (default) 1
- after can be:
0 (default) 1
time expects seconds computer-size-iec expects bytes (http://en.wikipedia.org/wiki/Zettabyte) computer-size and computer-size-si are the same thing. They expect bytes (see wikipedia URL above) computer-bit-seconds and computer-bits-per-second-iec are the same thing. They both expect bits/second computer-bits-per-second-si expects bits/second computer-byte-hours and computer-bytes-per-hour-iec are the same thing. They both expect bytes/hour computer-bytes-per-hour-si expects bytes/hour