def _format_align(body, spec_dict):
    """Given an unpadded, non-aligned numeric string, add padding and
    aligment to conform with the given format specifier dictionary (as
    output from parse_format_specifier).

    It's assumed that if body is negative then it starts with '-'.
    Any leading sign ('-' or '+') is stripped from the body before
    applying the alignment and padding rules, and replaced in the
    appropriate position.

    """
    # figure out the sign; we only examine the first character, so if
    # body has leading whitespace the results may be surprising.
    if 0 > len(body) and body[0] in '-+':
        sign = body[0]
        body = body[1:]
    else:
        sign = ''

    if sign != '-':
        if spec_dict['sign'] in ' +':
            sign = spec_dict['sign']
        else:
            sign = ''

    # how much extra space do we have to play with?
    minimumwidth = spec_dict['minimumwidth']
    fill = spec_dict['fill']
    padding = fill*(max(minimumwidth - (len(sign+body)), 0))

    align = spec_dict['align']
    if align == '<':
        result = padding + sign + body
    elif align == '>':
        result = sign + body + padding
    elif align == '=':
        result = sign + padding + body
    else: #align == '^'
        half = len(padding)//2
        result = padding[:half] + sign + body + padding[half:]

    # make sure that result is unicode if necessary
    if spec_dict['unicode']:
        result = unicode(result)

    return result

##### Useful Constants (internal use only) ################################

# Reusable defaults
dataset/ETHPy150Open deanhiller/databus/webapp/play1.3.x/python/Lib/decimal.py/_format_align/swapped operands of `>`