mltk.utils.string_formatting¶
String formatting utilities
See the source code on Github: mltk/utils/string_formatting.py
Functions
Convert human-readable string representing memory size to integer corresponding to memory size in bytes |
|
|
Convert the given numeric value to a string with units |
Return the current time as ISO 8601 format that is suitable for a filename e.g.: 2019-01-19T23-20-25-459 |
|
Return the current time as ISO 8601 format e.g.: 2019-01-19T23:20:25.459Z |
|
Return the current time as Y-m-d H-M-S |
- class FormattedInt[source]¶
-
- __dict__ = mappingproxy({'__module__': 'mltk.utils.string_formatting', '__str__': <function FormattedInt.__str__>, '__dict__': <attribute '__dict__' of 'FormattedInt' objects>, '__doc__': None, '__annotations__': {}})¶
- __module__ = 'mltk.utils.string_formatting'¶
- class FormattedFloat[source]¶
-
- __dict__ = mappingproxy({'__module__': 'mltk.utils.string_formatting', '__str__': <function FormattedFloat.__str__>, '__dict__': <attribute '__dict__' of 'FormattedFloat' objects>, '__weakref__': <attribute '__weakref__' of 'FormattedFloat' objects>, '__doc__': None, '__annotations__': {}})¶
- __module__ = 'mltk.utils.string_formatting'¶
- __weakref__¶
list of weak references to the object
- format_units(value, precision=3, add_space=True, ljust=0, rjust=0, memory_units=False)[source]¶
Convert the given numeric value to a string with units
Example: 0.0314 -> 31.4m
- Return type:
str
- Parameters:
value (Union[int, float]) –
precision (int) –
add_space (bool) –
ljust (int) –
rjust (int) –
memory_units (bool) –
- convert_units(v)[source]¶
Convert human-readable string representing memory size to integer corresponding to memory size in bytes
- e.g.:
‘32kb’ -> 32768 ‘2*128M’ -> 268435456
- Return type:
int
- Parameters:
v (str) –