Return size in B (bytes), kB, MB, GB or TB.

def prefix_size(size, base=1024):
    '''Return size in B (bytes), kB, MB, GB or TB.'''
    if ARGS.prefix == 'None':
        for i, prefix in enumerate(['', 'ki', 'Mi', 'Gi', 'Ti']):
            if size < pow(base, i + 1):
                return '{0} {1}B'.format(round(float(size) / pow(base, i), 1),
                                         prefix)
    else:
        try:
            prefix = {'': 0, 'k': 1, 'M': 2, 'G': 3, 'T': 4}[ARGS.prefix]
        except KeyError:
            exit('Invalid prefix.')
        return '{0} {1}B'.format(round(float(size) / pow(base, prefix), 1),
                                 ARGS.prefix)