(size_bytes)
| 166 | |
| 167 | |
| 168 | def readable_size(size_bytes): |
| 169 | if size_bytes <= 0: |
| 170 | return "0 B" |
| 171 | size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") |
| 172 | i = int(math.floor(math.log(size_bytes, 1024))) |
| 173 | p = math.pow(1024, i) |
| 174 | s = round(size_bytes / p, 2) |
| 175 | return f'{s} {size_name[i]}' |
no outgoing calls
no test coverage detected