2023-04-21 23:54:20 -06:00
|
|
|
from hurry.filesize import size
|
|
|
|
|
2023-05-30 00:46:53 -06:00
|
|
|
|
|
|
|
def filesize(bytes: int, spaces: bool = True, formatter: bool = True):
|
|
|
|
if formatter:
|
|
|
|
system = [
|
|
|
|
(1024 ** 5, ' PB'),
|
|
|
|
(1024 ** 4, ' TB'),
|
|
|
|
(1024 ** 3, ' GB'),
|
|
|
|
(1024 ** 2, ' MB'),
|
|
|
|
(1024 ** 1, ' KB'),
|
|
|
|
(1024 ** 0, ' B'),
|
|
|
|
]
|
|
|
|
x = size(bytes, system=system)
|
|
|
|
else:
|
|
|
|
x = size(bytes)
|
2023-04-21 23:54:20 -06:00
|
|
|
if spaces:
|
|
|
|
return x
|
|
|
|
else:
|
|
|
|
return x.replace(' ', '')
|