Get size in readable format
(size)
| 30 | |
| 31 | |
| 32 | def get_size(size): |
| 33 | """Get size in readable format""" |
| 34 | |
| 35 | units = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB"] |
| 36 | size = float(size) |
| 37 | i = 0 |
| 38 | while size >= 1024.0 and i < len(units): |
| 39 | i += 1 |
| 40 | size /= 1024.0 |
| 41 | return "%.2f %s" % (size, units[i]) |
| 42 | |
| 43 | def formate_file_name(file_name): |
| 44 | chars = ["[", "]", "(", ")"] |