import textwrap


def indent(text, n=0):
    """Re-indent a multi-line string, stripping leading newlines and trailing
    spaces."""
    text = text.lstrip('\n')
    text = textwrap.dedent(text)
    lines = text.split('\n')
    lines = [' '*n + l for l in lines]
    text = '\n'.join(lines)
    text = text.rstrip(' ')
    return text