| Conditions | 4 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # -*- coding: utf-8 -*- |
||
| 3 | def human_bytes(n): |
||
| 4 | """ |
||
| 5 | Return the number of bytes n in more human readable form. |
||
| 6 | """ |
||
| 7 | if n < 1024: |
||
| 8 | return '%d B' % n |
||
| 9 | k = n/1024 |
||
| 10 | if k < 1024: |
||
| 11 | return '%d KB' % round(k) |
||
| 12 | m = k/1024 |
||
| 13 | if m < 1024: |
||
| 14 | return '%.1f MB' % m |
||
| 15 | g = m/1024 |
||
| 16 | return '%.2f GB' % g |
||
| 17 | |||
| 24 |