MCPcopy Index your code
hub / github.com/TechifyBots/File-Stream-Bot / humanbytes

Function humanbytes

biisal/utils/human_readable.py:6–17  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

4
5
6def humanbytes(size):
7 # https://stackoverflow.com/a/49361727/4723940
8 # 2**10 = 1024
9 if not size:
10 return ""
11 power = 2**10
12 n = 0
13 Dic_powerN = {0: ' ', 1: 'Ki', 2: 'Mi', 3: 'Gi', 4: 'Ti'}
14 while size > power:
15 size /= power
16 n += 1
17 return str(round(size, 2)) + " " + Dic_powerN[n] + 'B'

Callers 2

render_pageFunction · 0.90
private_receive_handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected