def sizeof_fmt(num, suffix='B'):
    """
    Calculates file size in human-readable format.
    Copy-pasted from StackOverflow, thanks to this dude:
    https://stackoverflow.com/questions/1094841/
    reusable-library-to-get-human-readable-version-of-file-size
    """
    for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
        if abs(num) < 1024.0:
            return '%3.1f%s%s' % (num, unit, suffix)
        num /= 1024.0
    return '%.1f%s%s' % (num, 'Yi', suffix)
