MCPcopy Index your code
hub / github.com/secdev/scapy / human_size

Function human_size

scapy/utils.py:3388–3399  ·  view source on GitHub ↗

Convert a size in octets to a human string representation

(x, fmt=".1f")

Source from the content-addressed store, hash-verified

3386
3387
3388def human_size(x, fmt=".1f"):
3389 # type: (int, str) -> str
3390 """
3391 Convert a size in octets to a human string representation
3392 """
3393 units = ['K', 'M', 'G', 'T', 'P', 'E']
3394 if not x:
3395 return "0B"
3396 i = int(math.log(x, 2**10))
3397 if i and i < len(units):
3398 return format(x / 2**(10 * i), fmt) + units[i - 1]
3399 return str(x) + "B"
3400
3401
3402def __make_table(

Callers 3

ls_outputMethod · 0.90
lls_outputMethod · 0.90
get_outputMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected