mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-01-16 14:01:20 -05:00
* docs: 📝 general documentation + add FAQ page * fix(frontend): 🐛 readd missing upload button to backups. * feat(backend): ✨ add support for backup sizes to be displayed on frontend * feat(backend): ✨ add backend for administrator CRUD of users * add admin support for user * refactor(frontend): ♻️ rewrite admin CRUD interface for admins * fix build errors Co-authored-by: hay-kot <hay-kot@pm.me>
16 lines
552 B
Python
16 lines
552 B
Python
def pretty_size(size: int) -> str:
|
|
"""
|
|
Pretty size takes in a integer value of a file size and returns the most applicable
|
|
file unit and the size.
|
|
"""
|
|
if size < 1024:
|
|
return f"{size} bytes"
|
|
elif size < 1024 ** 2:
|
|
return f"{round(size / 1024, 2)} KB"
|
|
elif size < 1024 ** 2 * 1024:
|
|
return f"{round(size / 1024 / 1024, 2)} MB"
|
|
elif size < 1024 ** 2 * 1024 * 1024:
|
|
return f"{round(size / 1024 / 1024 / 1024, 2)} GB"
|
|
else:
|
|
return f"{round(size / 1024 / 1024 / 1024 / 1024, 2)} TB"
|