toil.lib.conversions¶
Conversion utilities for mapping memory, disk, core declarations from strings to numbers and vice versa. Also contains general conversion functions
Attributes¶
Functions¶
|
|
|
Returns a float representing the converted input in dst_units. |
|
Given a string representation of some memory (i.e. '1024 Mib'), return the |
|
Given a string representation of some memory (i.e. '1024 Mib'), return the |
|
Return a binary value as a human readable string with units. |
|
Convert a number from bytes to mibibytes. |
|
Convert a number from mibibytes to bytes. |
Parses a given time string in hours:minutes:seconds, |
|
|
Make a human-readable string into a bool. |
Convert an optional string representation of bool to None or bool |
Module Contents¶
- toil.lib.conversions.BINARY_PREFIXES = ['ki', 'mi', 'gi', 'ti', 'pi', 'ei', 'kib', 'mib', 'gib', 'tib', 'pib', 'eib']¶
- toil.lib.conversions.DECIMAL_PREFIXES = ['b', 'k', 'm', 'g', 't', 'p', 'e', 'kb', 'mb', 'gb', 'tb', 'pb', 'eb']¶
- toil.lib.conversions.VALID_PREFIXES = ['ki', 'mi', 'gi', 'ti', 'pi', 'ei', 'kib', 'mib', 'gib', 'tib', 'pib', 'eib', 'b', 'k', 'm',...¶
- toil.lib.conversions.convert_units(num, src_unit, dst_unit='B')[source]¶
Returns a float representing the converted input in dst_units.
- toil.lib.conversions.parse_memory_string(string)[source]¶
Given a string representation of some memory (i.e. ‘1024 Mib’), return the number and unit.
- toil.lib.conversions.human2bytes(string)[source]¶
Given a string representation of some memory (i.e. ‘1024 Mib’), return the integer number of bytes.
- toil.lib.conversions.bytes2human(n)[source]¶
Return a binary value as a human readable string with units.
- Parameters:
n (SupportsInt)
- Return type:
- toil.lib.conversions.hms_duration_to_seconds(hms)[source]¶
Parses a given time string in hours:minutes:seconds, returns an equivalent total seconds value