mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2026-01-04 11:24:50 +00:00
Change readable code
This commit is contained in:
parent
9465811244
commit
041b9fe856
1 changed files with 2 additions and 5 deletions
|
|
@ -5,13 +5,10 @@ def get_readable_file_size(size_in_bytes) -> str:
|
||||||
if size_in_bytes is None:
|
if size_in_bytes is None:
|
||||||
return "0B"
|
return "0B"
|
||||||
index = 0
|
index = 0
|
||||||
while size_in_bytes >= 1024:
|
while size_in_bytes >= 1024 and index < len(SIZE_UNITS) - 1:
|
||||||
size_in_bytes /= 1024
|
size_in_bytes /= 1024
|
||||||
index += 1
|
index += 1
|
||||||
try:
|
return f"{size_in_bytes:.2f} {SIZE_UNITS[index]}" if index > 0 else f"{size_in_bytes}B"
|
||||||
return f"{round(size_in_bytes, 2)}{SIZE_UNITS[index]}"
|
|
||||||
except IndexError:
|
|
||||||
return "File too large"
|
|
||||||
|
|
||||||
|
|
||||||
def get_readable_time(seconds: int) -> str:
|
def get_readable_time(seconds: int) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue