mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44: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:
|
||||
return "0B"
|
||||
index = 0
|
||||
while size_in_bytes >= 1024:
|
||||
while size_in_bytes >= 1024 and index < len(SIZE_UNITS) - 1:
|
||||
size_in_bytes /= 1024
|
||||
index += 1
|
||||
try:
|
||||
return f"{round(size_in_bytes, 2)}{SIZE_UNITS[index]}"
|
||||
except IndexError:
|
||||
return "File too large"
|
||||
return f"{size_in_bytes:.2f} {SIZE_UNITS[index]}" if index > 0 else f"{size_in_bytes}B"
|
||||
|
||||
|
||||
def get_readable_time(seconds: int) -> str:
|
||||
|
|
|
|||
Loading…
Reference in a new issue