MCPcopy Create free account
hub / github.com/VJBots/VJ-File-Store / humanbytes

Function humanbytes

TechVJ/utils/human_readable.py:5–16  ·  view source on GitHub ↗
(size)

Source from the content-addressed store, hash-verified

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

Callers 1

render_pageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected