formatter
This commit is contained in:
parent
b74a52a6db
commit
37f8a33a86
10
program/utils/formatters.py
Normal file
10
program/utils/formatters.py
Normal file
@ -0,0 +1,10 @@
|
||||
def bytes(size: float) -> str:
|
||||
if not size:
|
||||
return ""
|
||||
power = 1024
|
||||
t_n = 0
|
||||
power_dict = {0: " ", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"}
|
||||
while size > power:
|
||||
size /= power
|
||||
t_n += 1
|
||||
return "{:.2f} {}B".format(size, power_dict[t_n])
|
Loading…
Reference in New Issue
Block a user