client.units

Classes

TimeUnit

A helper class provides static functions to switch among seconds, minutes, and hours.

MemUnit

A helper class to convert memory units between B, k, K, m, M, g, G, t, T.

Module Contents

class client.units.TimeUnit(sec: int = 0, min: float = 0.0, hour: float = 0.0)[source]

A helper class provides static functions to switch among seconds, minutes, and hours.

It also can be initialized with combined input of seconds, minutes, and hours, and converts them to any single time unit.

static min_to_sec(minutes: float) int[source]

Static helper function to turn minutes into seconds. Accept pointers.

static hour_to_sec(hour: float) int[source]

Static helper function to turn minutes into seconds.

static hour_to_min(hour: float) float[source]

Static helper function to turn minutes into seconds.

static min_to_hour(min: float) float[source]

Static helper function to turn minutes into seconds.

static sec_to_hour(sec: int) float[source]

Static helper function to turn minutes into seconds.

static sec_to_min(sec: int) float[source]

Static helper function to turn minutes into seconds.

seconds[source]
minutes[source]
hours[source]
readable[source]
class client.units.MemUnit[source]

A helper class to convert memory units between B, k, K, m, M, g, G, t, T.

base_chart_to_B[source]
static _split_unit(input: str) Tuple[int, str][source]

Split the number and the unit. Return 0 M for invalid; use M when no unit.

static _to_B(input: str) int[source]
static convert(input: str, to: str = 'M') int[source]

Convert memory to different units.

input: a string in format “1G”, “1g”, “1Gib”, “1gb”,etc. to: the unit to convert to; takes B, K, M, G, T. Lower case unit will be treated as capital. Return: an int of the memory value of your specified unit