@register.filter
def humanreadablesize(kbytes):
    """Returns sizes in human-readable units. Input is kbytes"""
    try:
        kbytes = float(kbytes)
    except (TypeError, ValueError, UnicodeDecodeError):
        return "unknown"
        
    units = [(" KB", 2**10), (" MB", 2**20), (" GB", 2**30), (" TB", 2**40)]
    for suffix, limit in units:
        if kbytes > limit:
            continue
        else:
            return str(round(float(limit/2**10)/kbytes, 1)) + suffix
dataset/ETHPy150Open munki/munkiwebadmin/reports/templatetags/report_extras.py/humanreadablesize/swapped operands of `/`