modunits module

Convert computer-friendly numbers to human-readable numbers with units at various levels of detail.

class modunits.Item(amount: float, type_: modunits.Type, after: bool, units: str, fractional_part_length: int)[source]

Bases: object

Hold one of the modular pieces of our number.

class modunits.Options[source]

Bases: object

Hold, parse and verify command line options.

check_options() None[source]

Verify that the options specified make sense.

parse_argv(argv: List[str]) None[source]

Dissect our argv into something useful.

class modunits.Type(threshold: Optional[int], unabbreviated: str, abbreviated: str)[source]

Bases: object

Hold data about whether we should output units abbreviated or unabbreviated, and what to divide by (?).

modunits.builtins() List[str][source]

Legal options for builtin varieties of modular units.

modunits.detail_options() List[str][source]

Legal options for what level of detail we want.

modunits.main() None[source]

Convert to human-readable form of units.

modunits.modunits(unitsvector: Union[str, List[modunits.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.

modunits.units_type() List[str][source]

Legal options for abbreviation or not.

modunits.usage(retval: int) None[source]

Give usage message to user.