def convert_size(free, total, mode):
    """
    Takes free and total size and coverts them based on conversion mode

    free - returns free
    total - returns total
    used - returns difference between total and free
    pfree - returns free as percentage of total
    pused - returns used as percentage of total

    :param mode: one of SIZE_CONVERSION_MODES
    """
    if total == 0:
        return 0  # even if free is not 0, it is better to alert authorities
    value = None
    if mode == 'free':
        value = free
    elif mode == 'total':
        value = total
    elif mode == 'used':
        value = total - free
    elif mode == 'pfree':
        value = (free / total) * 100
    elif mode == 'pused':
        used = (total - free)
        value = (used / total) * 100
    return value