forked from TrueCloudLab/frostfs-testlib
Add repr and str for most classes used in parametrize
Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
This commit is contained in:
parent
38742badf2
commit
2240be09d2
14 changed files with 187 additions and 48 deletions
|
@ -1,10 +1,23 @@
|
|||
import base64
|
||||
import binascii
|
||||
import json
|
||||
from typing import Tuple
|
||||
|
||||
import base58
|
||||
|
||||
|
||||
def calc_unit(value: float, skip_units: int = 0) -> Tuple[float, str]:
|
||||
units = ["B", "KiB", "MiB", "GiB", "TiB"]
|
||||
|
||||
for unit in units[skip_units:]:
|
||||
if value < 1024:
|
||||
return value, unit
|
||||
|
||||
value = value / 1024.0
|
||||
|
||||
return value, unit
|
||||
|
||||
|
||||
def str_to_ascii_hex(input: str) -> str:
|
||||
b = binascii.hexlify(input.encode())
|
||||
return str(b)[2:-1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue