summaryrefslogtreecommitdiffstats
path: root/src/fringlib/fringutil.py
blob: e174d6639293ef81c25708f153bf745a63890714 (plain)
1
2
3
4
5
6
7
8
9
10
11
12

def pretty_size(size):
    if size >= 1024*1024*1024:
        return "%.1f GiB" % round(size/1024/1024/1024.0)
    elif size >= 1024*1024:
        return "%.1f MiB" % round(size/1024/1024.0)
    elif size >= 1024:
        return "%.1f KiB" % round(size/1024.0)
    else:
        return "%u B" % size