Created
February 27, 2023 20:48
-
-
Save IamMiracleAlex/1f33331f837e6228473ac6bc0a59043f to your computer and use it in GitHub Desktop.
Calculates storage size and returns the value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculate_size(size): | |
""" | |
Calculates storage size and returns the value | |
A single record is 1kb | |
""" | |
for x in ["KB", "MB", "GB", "TB"]: | |
if size < 1000.0: | |
return "%3.1f %s" % (size, x) | |
size /= 1000.0 | |
return size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment